#C13858. Second Most Frequent Character

    ID: 43442 Type: Default 1000ms 256MiB

Second Most Frequent Character

Second Most Frequent Character

You are given a string S consisting of ASCII characters. Your task is to determine the second most frequent character in the string.

Let \( f(c) \) denote the frequency of character \( c \) in S. First, list all the distinct characters and their frequencies. Then sort the characters primarily in descending order of their frequencies and, in case of ties, in lexicographical order (i.e. alphabetical order). The answer is the character that comes in the second position of this sorted order.

If the string does not contain at least two distinct characters, output None.

Note: The tie-breaking rule is defined by lexicographical order.

inputFormat

The input consists of a single line containing the string S. The string may include spaces and punctuation.

outputFormat

Print the second most frequent character according to the rules described. If such a character does not exist (i.e. there are fewer than two distinct characters), print None.

## sample
aaabbbbcc
a