#include<cstdio>
#include<map>
#include<cctype>
#include<cstring>
#include<iostream>
#include<string>
using namespace std;

char st[1048596],key[1048596];

int main(){
	string str,temp;
	map<string,int> mp;
	getline(cin, str);
	int k=0;
	for(int i=0;i<str.size();i++){
		if(isalnum(str[i])){
			key[k++]=str[i];
			if(i== str.size()-1 && k!=0) 	{
				for(int i=0;i<k;i++){
					if(key[i]>='A'&& key[i]<='Z'){  //大写字母变小写 
						key[i]=key[i] + 32;
					}
				}
				key[k]='\0';
				temp = key;
				mp[temp]++;
			
			}
			
		}else{
			if(k!=0) {
				for(int i=0;i<k;i++){
					if(key[i]>='A'&& key[i]<='Z'){  //大写字母变小写 
						key[i]=key[i] + 32;
					}
				}
				key[k]='\0';
				temp = key;
				mp[temp]++;
			}
			k=0;
		}
	}
	
	int maxT=0;
	string ans;
	map<string ,int >::iterator it;
	for( it=mp.begin();it!=mp.end();it++){  //求出最大值 
		if(it->second > maxT) {
			maxT = it->second;
			ans = it->first;
		}
	} 
	cout<<ans<<" "<<maxT<<endl;
	
	return 0;
}