Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/string-eng-kop-uchragan-soz

Most frequent word

Medium 1000 ms 128 MB 49%
Share

A text $s$ of lowercase Latin letters and spaces is given. Find the word that occurs in the text most often and how many times it occurs. If several words are tied, take the one that comes first in dictionary order. Words are separated by a single space.

Counting how often each word occurs and finding the most frequent

Input

One line containing the string $s$.

Output

One line with the word and the number of its occurrences separated by a space.

Note

$1 \le |s| \le 10^{5}$
$s$ consists of lowercase Latin letters and spaces
$s$ does not start or end with a space, and words are separated by exactly one space

Examples

Input #1
olma anor olma nok anor olma
Output #1
olma 3
Input #2
nok uzum
Output #2
nok 1

Sign in to submit a solution

Signing up is free and takes a minute.