a=[]

a=input().split()

for i in range(5):

 if a[i]=='0':

  print((str(i+1)))

 else:

  pass

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

for i in range(5):

  if s[i]==0:

     print((i+1))

     exit()

  else:

     pass
a = []
a = input().split()
for i in range(5):
    if a[i] == "0":
        print((str(i + 1)))
    else:
        pass

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

-a = [] -a = input().split() +s = list(map(int, input().split())) -    if a[i] == "0": -        print((str(i + 1))) +    if s[i] == 0: +        print((i + 1)) +        exit()