#include<iostream>
#include<string>
using namespace std;

int main(){
    string str[1001],tmp;
    int max_num = 0,max_length=0,i,max = 0,max_str = 0,length = 0,a[1001] = {};
    
    while(cin>>tmp){
        for(i = 0;i < tmp.size();i++){
            if('A' <= tmp[i] && tmp[i] <= 'Z')
                tmp[i] = tmp[i] + 'a' - 'A';
        }
        
        for(i = 0;i < max;i++){
            if(str[i] == tmp){
                a[i]++;
                if(max_str < a[i]){
                    max_str = a[i];
                    max_num = i;
                }
                if(tmp.size() > max_length)
                    length = (int)tmp.size();
                    
            }
        }
        if(i >= max){
            str[i] = tmp;
        }
    }
    cout<<str[max_num]<<endl;
    
    for(i = 0;i < max;i++){
        if((int)str[i].size() == length)
            cout<<str[i]<<endl;
    }
    return 0;
}