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