from collections import Counter


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

    S = input()
    c = Counter(S)

    for k in r:
        if r[k] > c[k]:
            to = k
        elif r[k] < c[k]:
            fr = k

    print(fr, to)


if __name__ == '__main__':
    solve()