# import sys; input = sys.stdin.buffer.readline # sys.setrecursionlimit(10**7) from collections import defaultdict con = 10 ** 9 + 7; INF = float("inf") def getlist(): return list(map(int, input().split())) L = [20104, 20063, 19892, 20011, 19874, 20199, 19898, 20163, 19956, 19841] #処理内容 def main(): table = [0] * 10 s = input() for i in s: if i != ".": table[int(i)] += 1 a = None b = None for i in range(10): if L[i] > table[i]: b = i elif L[i] < table[i]: a = i print(a, b) if __name__ == '__main__': main()