// 我很菜 所以寫的可能比較亂 或是跑比較慢
// 如果有人有更好的方式可以sort那個dict麻煩和我說一下 感謝!
'''
https://zerojudge.tw/ShowProblem?problemid=c012
c012. 10062 - Tell me the frequencies!
'''
while True:
try:
s = str(input())
d_dict = {}
for i in s:
i = ord(i)
if i not in d_dict:
d_dict[i] = 1
else:
d_dict[i] += 1
d_dict = dict(sorted(d_dict.items(), key = lambda x : (x[1], -x[0]), reverse = False))
for key,item in d_dict.items():
print(key, item)
except:
break