import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from collections import Counter counter = Counter(read().rstrip().decode('utf-8')) pi = {'3': 20011, '.': 1, '1': 20063, '4': 19874, '5': 20199, '9': 19841, '2': 19892, '6': 19898, '8': 19956, '7': 20163, '0': 20104} a,b = None,None # 余分、足りない for i in range(10): w = str(i) if pi[w] > counter[w]: b = i elif pi[w] < counter[w]: a = i print(a,b)