zero = 0
one = 0
for i in range(5):
num = int(input())
if num == 0:
zero += 1
if num == 1:
one += 1
print(min(zero, one))
zero = 0
one = 0
for i in range(5):
num = int(input())
if num == 0:
zero += 1
if num == 1:
one += 1
print(min(zero, one))