#include <iostream>
#include <cstring>
#include<map>
#include<cmath>
using namespace std;
map<string,int>mp;
bool check(char ch){
if(isalpha(ch)) return true;
//isalpha(ch)是判断ch是否是英文字母,大写返回2,小写返回1,否则返回0
if(ch>='0'&&ch<='9')return true;
return false;
}
int main() {
string str;
string word;
//将输入流的字符串放在str中,默认遇到回车停止
getline(cin,str);
for(int i=0;i<str.length();i++){
if(check(str[i])){
if(isupper(str[i]))
ss[i]+=32;
word+=str[i];//将ss[i]拼接到word
}
if(i==str.length()-1||check(str[i])==0) //如果str[i]非英文字母或者遍历到最后一个字符
{
//如果单词长度不为0,则单词出现的次数加一
if(word.length()!=0){
mp[word]++; //mp[word]表示单词出现的次数,键是单词,值是次数
}
word.clear();
}
}
int mx=-1;
string ans;
map<string,int>::iterator it;
for(it=mp.begin();it!=mp.end();it++) //依次遍历mp,mp会默认以键的大小由小到大排序
{
//求出最大的值,并将单词赋给ans,次数赋给mx;如果有相等的mx,
//取mx原先取到的单词,也就是按字典排序更小的单词
if(it->second>mx){
mx=it->second;
ans=it->first;
}
}
cout<<ans<<" "<<mx;
return 0;
}