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