# coding: utf-8 import array, bisect, collections, heapq, itertools, math, random, re, string, sys, time sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 MOD = 10 ** 9 + 7 def II(): return int(input()) def ILI(): return list(map(int, input().split())) def IAI(LINE): return [ILI() for __ in range(LINE)] def IDI(): return {key: value for key, value in ILI()} def solve(S): pi = [20104, 20063, 19892, 20011, 19874, 20199, 19898, 20163, 19956, 19841] count = [S.count(str(i)) for i in range(10)] for i in range(10): if count[i] < pi[i]: y = i if count[i] > pi[i]: x = i ans = [x, y] return ans def main(): S = input() ans = solve(S) print("{0} {1}".format(ans[0], ans[1])) if __name__ == "__main__": main()