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