line = [int(i) for i in input().split()] if line[0] != 1: print("1") elif line[8] != 10: print("10") else: for i in range(9): val = line[i] if line[i+1] != val + 1: print(val + 1) break