a = raw_input() cnt = [a.count(str(x)) for x in xrange(10)] ans = [20104, 20063, 19892, 20011, 19874, 20199, 19898, 20163, 19956, 19841] f = 0 t = 0 for x in xrange(10): if cnt[x] > ans[x]:f = x if cnt[x] < ans[x]:t = x print f,t