dic = { "3": 20011, ".": 1, "1": 20063, "4": 19874, "5": 20199, "9": 19841, "2": 19892, "6": 19898, "8": 19956, "7": 20163, "0": 20104, } S = input() a, b = 0, 0 for i in range(10): if S.count(str(i)) > dic[str(i)]: a = i if S.count(str(i)) < dic[str(i)]: b = i print(a, b)