S = input() cnt = {'1': 20069, '4': 19880, '5': 20203, '9': 19846, '2': 19902, '6': 19911, '3': 20017, '8': 19964, '7': 20166, '0': 20111, '.': 1} for c in S: cnt[c] -= 1 cnt = sorted(cnt.items(), key=lambda x: x[1]) print(cnt[-1][0], cnt[0][1])