#include <cstdio>
#include <string>
#include <map>
#include <iostream>

using namespace std;

string s1, s2;
int maxlen = 0, mode = 0;
map<string,int> mp;

int main()
{   
    int m = 9;
    while( cin >> s2 )
    {
        if( s2 == "\n" )break;
        mp[s2]++;
    }
    for( auto x : mp )
    {
        if( maxlen < sizeof( x.first ) )
        {
            maxlen = sizeof( x.first ); 
        } 
        if( mode < x.second )
        {
            mode = x.second;
        }
        printf( "%d", x.second );
    }

    for( auto x : mp )
    {
        if( maxlen == sizeof( x.first ) )
        {
            printf( "%s", x.first );
        }
        if( mode == x.second )
        {
            printf( "%s ", x.first );
        }
    }
    return 0;
}

