x = [int(i) for i in input().split()]

for i in range(5):

    if x[i] == 0:

        print((i+1))

        break
x = [int(i) for i in input().split()]

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

x = [int(i) for i in input().split()]
print((x.index(0) + 1))

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