#include<stdio.h>#include<iostream>#include<string>#include<map>usingnamespace std;boolisLegal(char c){if(c >='0'&& c <='9')returntrue;if(c >='a'&& c <='z')returntrue;if(c >='A'&& c <='Z')returntrue;returnfalse;}boolisCap(char c){if(c >='A'&& c <='Z')returntrue;returnfalse;}
map<string,int> count;intmain(){
string str, res;int max =0;while(1){int index =0;
string str2;
cin >> str;for(int i =0; i < str.length(); i++){if(isLegal(str[i])){if(isCap(str[i])){
str[i]= str[i]+'a'-'A';}
str2 += str[i];
index++;}}if(str2 !=""){if(count.find(str2)!= count.end()){
count[str2]++;}else count[str2]=1;}if(getchar()=='\n')break;}for(map<string,int>::iterator it = count.begin(); it != count.end(); it++){if(it->second > max){
max = it->second;
res = it->first;}}
cout << res <<" "<< max << endl;return0;}