#K46422. Most Frequent Digit

    ID: 27973 Type: Default 1000ms 256MiB

Most Frequent Digit

Most Frequent Digit

You are given a non-negative integer n. Your task is to determine the digit that appears most frequently in the decimal representation of n. In case of a tie, return the largest digit among those that appear most frequently.

Note: The input will be provided via standard input (stdin) and the output should be written to standard output (stdout).

Examples:

  • For n = 122333, the output is 3.
  • For n = 9876543210, the output is 9.
  • For n = 1122334455, all digits appear equally; hence the output is 5 (the largest among those tied).

inputFormat

The input consists of a single line containing a non-negative integer n.

You should read the input from standard input.

outputFormat

Output a single integer: the digit that appears most frequently in n. In case of a tie, output the largest digit among those tied.

The output should be written to standard output.

## sample
122333
3