n=[20104,20063,19892,20011,19874,20199,19898,20163,19956,19841] s=input() l=[n[i]-s.count(str(i)) for i in range(10)] a=l.index(1) w=l.index(-1) print(w,a)