#K2746. Most Frequent First Character

    ID: 24805 Type: Default 1000ms 256MiB

Most Frequent First Character

Most Frequent First Character

You are given a sentence as input. Your task is to find the most frequent first character among its words, ignoring punctuation and case, and considering only letters. In other words, for each word, remove any punctuation, convert letters to lower case, and then examine its first letter. If there is a tie (i.e. multiple characters share the same highest frequency), return the one that appears first in the original sentence.

Formally, let ( S ) be the input sentence, and let each word ( w_i ) be cleaned to ( c_i ) by removing all non-alphanumeric characters and converting to lowercase. Find the letter ( x ) such that its frequency ( f(x) = \max{ f(y) } ) over all first characters of ( c_i ). In case multiple letters have the same frequency, output the one corresponding to the earliest occurrence in ( S ).

inputFormat

The input is a single string representing the sentence. Read the entire input from stdin.

outputFormat

Output a single character (via stdout) which is the most frequent first character of the words based on the criteria described. Output an empty string if no valid letter exists.## sample

Hello world!
H