import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) pi_count = [20104, 20063, 19892, 20011, 19874, 20199, 19898, 20163, 19956, 19841] count = [0]*10 S = S() for i in range(10): count[i] = S.count(str(i)) for i in range(10): if count[i] > pi_count[i]: ans0 = i elif count[i] < pi_count[i]: ans1 = i print(ans0,ans1)