#include <iostream>
#include <string>
#include <string.h>
#include <map>
using namespace std;
char s[1048580], cur[1048580], res[1048580];
int judge(char ch)
{
if((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z'))
{
return 1;
}
return 0;
}
int main()
{
gets(s);
int len = strlen(s), i;
char ch;
for(i = 0; i < len; i++)
{
ch = s[i];
if(ch >= 'A' && ch <= 'Z')
{
s[i] = ch + 32;
}
}
i = 0;
int j;
map<string, int> m;
while(i < len)
{
while(i < len)
{
ch = s[i];
if(judge(ch) == 1)
{
break;
}
i++;
}
if(i == len)
{
break;
}
j = 0;
while(i < len && judge(s[i]) == 1)
{
cur[j++] = s[i++];
}
cur[j] = '\0';
m[cur]++;
i++;
}
map<string, int> ::iterator it;
int max = 0, second;
for(it = m.begin(); it != m.end(); it++)
{
second = it->second;
if(second > max)
{
max = second;
strcpy(res, (it->first).c_str());
}
}
printf("%s %d\n", res, max);
system("pause");
return 0;
}