#include<bits/stdc++.h>
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
string s;
getline(cin,s);
getchar();
transform(s.begin(),s.end(),s.begin(),::tolower);
map<string,int> hash;
string temp;
for(int i=0;i<s.length();i++){
if((s[i]<='9'&&s[i]>='0')||(s[i]>='a'&&s[i]<='z')){
temp=temp+s[i];
}else if(temp!=""){
hash[temp]++;
temp.erase(0,temp.size());
}
}
map<string,int>::iterator it;
string maxstring;
int maxnum=0;
for(it=hash.begin();it!=hash.end();it++){
if(it->second>maxnum){
maxnum=it->second;
maxstring=it->first;
}
}
cout<<maxstring<<' '<<maxnum;
return 0;
}