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



for a in range(5):

    if x[a] == 0:

        print((a+1))

        break

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

print((15 - sum(x)))

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

x = list(map(int, input().split()))
print((15 - sum(x)))

-for a in range(5): -    if x[a] == 0: -        print((a + 1)) -        break +print((15 - sum(x)))