from collections import defaultdict countedPi = {'3': 20011, '1': 20063, '4': 19874, '5': 20199, '9': 19841, '2': 19892, '6': 19898, '8': 19956, '7': 20163, '0': 20104} counter = defaultdict(int) pi = str(input()) for s in pi: counter[s] += 1 illegalNumber = 0 collectNumber = 0 for k in counter.keys(): if countedPi[k] != counter[k]: if counter[k] > countedPi[k]: illegalNumber = k else: collectNumber = k print(str(illegalNumber) + " " + str(collectNumber))