

if __name__ == "__main__":



    a = eval(input())

    b = eval(input())

    print((sum([a[i] == b[i] for i in range(3)])))

    
#n = input()

#a = list(map(int, input().split()))

#b = list(map(int, input().split()))

#c = list(map(int, input().split()))

a = eval(input())

b = eval(input())

r = 0

for i,j in zip(a, b):

    r += i == j

print(r)
if __name__ == "__main__":
    a = eval(input())
    b = eval(input())
    print((sum([a[i] == b[i] for i in range(3)])))

# n = input()
# a = list(map(int, input().split()))
# b = list(map(int, input().split()))
# c = list(map(int, input().split()))
a = eval(input())
b = eval(input())
r = 0
for i, j in zip(a, b):
    r += i == j
print(r)

-if __name__ == "__main__": -    a = eval(input()) -    b = eval(input()) -    print((sum([a[i] == b[i] for i in range(3)]))) +# n = input() +# a = list(map(int, input().split())) +# b = list(map(int, input().split())) +# c = list(map(int, input().split())) +a = eval(input()) +b = eval(input()) +r = 0 +for i, j in zip(a, b): +    r += i == j +print(r)