s,t=eval(input()),eval(input());print((len([1 for i in range(3) if s[i]==t[i]])))
print((len([1 for i,j in zip(eval(input()),eval(input())) if i==j])))
s, t = eval(input()), eval(input())
print((len([1 for i in range(3) if s[i] == t[i]])))

print((len([1 for i, j in zip(eval(input()), eval(input())) if i == j])))

-s, t = eval(input()), eval(input()) -print((len([1 for i in range(3) if s[i] == t[i]]))) +print((len([1 for i, j in zip(eval(input()), eval(input())) if i == j])))