X_s = list(map(int, input().split()))



for i in range(len(X_s)):

    num = X_s[i]



    if (num == 0):

        print((i + 1))
X_s = list(map(int, input().split()))

 

for i in range(len(X_s)):

    num = X_s[i]

 

    if (num == 0):

        print((i + 1))

        break
X_s = list(map(int, input().split()))
for i in range(len(X_s)):
    num = X_s[i]
    if num == 0:
        print((i + 1))

X_s = list(map(int, input().split()))
for i in range(len(X_s)):
    num = X_s[i]
    if num == 0:
        print((i + 1))
        break

+        break