cnt = {'5': 20199, '7': 20163, '0': 20104, '1': 20063, '3': 20011, '8': 19956, '6': 19898, '2': 19892, '4': 19874, '9': 19841, '.': 1}

from collections import Counter

S = input()
cnt_ = Counter(S)
a, b = None, None
for i in range(10):
    i = str(i)
    if cnt_[i] < cnt[i]:
        b = i
    elif cnt_[i] > cnt[i]:
        a = i

print(a, b)