x = input().split(" ") for i in range(9): if "9" == x[i]: print("10") break elif str(i+1) == x[i]: pass else: print(i+1) break