N = list(eval(input()))

ans = N.count("2")

print(ans)
N = eval(input())

ans = N.count("2")

print(ans)
N = list(eval(input()))
ans = N.count("2")
print(ans)

N = eval(input())
ans = N.count("2")
print(ans)

-N = list(eval(input())) +N = eval(input())