# coding: utf-8
# lang: Ruby(2.3.3)
# submission # - User: herp_sy
# https://atcoder.jp/contests/
# ------------------------------------------------------------

s = gets.split('')
t = gets.split('')

cnt = 0
for i in 0..2 do
	if s[i] == t[i]
		cnt += 1
	end
end

p cnt
