initial_input = input() num = initial_input.split(" ") ans = 0 for i in range(8): if int(num[i + 1]) - int(num[i]) == 2: ans = int(num[i]) + 1 break if ans == 0: if num[0] == "2": ans = 1 else: ans = 10 print(ans)