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



for i in range(len(array)):

    if array[i] == 0:

        print((i+1))

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



for i in range(len(lista)):

    if lista[i] == 0:

        print((i+1))

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

lista = [int(x) for x in input().split()]
for i in range(len(lista)):
    if lista[i] == 0:
        print((i + 1))
        exit()

-array = list(map(int, input().split())) -for i in range(len(array)): -    if array[i] == 0: +lista = [int(x) for x in input().split()] +for i in range(len(lista)): +    if lista[i] == 0: -        break +        exit()