while True:
try:
cmp=[0]*100;result=[]
a= input()
for i in a:
ans=ord(i)
if ord("A")<=ans<ord("Z") or ord("a")<=ans<ord("z") :
ans=ord(i)-65#;print(ans)
cmp[ans]+=1
mymax=0
for i in range(len(cmp)):
mymax=max(mymax,cmp[i])
for j in range(len(cmp)):
if cmp[j]==mymax:
result.append(chr(j+65))
word=""
for u in range(len(result)):
word+=result[u]
print(word,mymax)
except EOFError:
break