B=list(map(int,input().split())) for i in range(0,8): if B[i]+1!=B[i+1]: print(B[i]+1) break if B[8]==9: print(10)