from collections import Counter c = Counter(input()) l=sorted(c.items(), key=lambda s:(-s[1], s[0])) for i in l[:3]: print(' '.join(map(str, list(i))))