Bn = list(map(int,input().split())) L = range(1,10) i = 0 while Bn[i] == L[i]: i += 1 if i == 9: i -= 1 break print(L[i])