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

for i in range(5):

  if x[i] == 0:

    print((i+1))

    exit()

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

print((x.index(0)+1))
x = list(map(int, input().split()))
for i in range(5):
    if x[i] == 0:
        print((i + 1))
        exit()

x = list(map(int, input().split()))
print((x.index(0) + 1))

-for i in range(5): -    if x[i] == 0: -        print((i + 1)) -        exit() +print((x.index(0) + 1))