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()))



for i in range(5):

    if x[i] == 0:

        print((i + 1))

        break

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()))
for i in range(5):
    if x[i] == 0:
        print((i + 1))
        break

-        exit() +        break