try:
while True:
a = input()
count = 0
temp = a[0]
max_count = 1
for x in a:
if temp == x:
count += 1
if max_count < count:
max_count = count
max_alph = temp
else:
pass
else:
if max_count < count:
max_count = count
max_alph = temp
else:
pass
count = 1
temp = x
print(max_alph, max_count)
except EOFError:
pass