s = gets.chomp
t = gets.chomp
news0 = s[0]
newt0 = t[0]
news1 = s[1]
newt1 = t[1]
news2 = s[2]
newt2 = t[2]
result = 0

if news0 == newt0
  result += 1
end
if news1 == newt1
  result += 1
end
if news2 == newt2
  result += 1
end

p result
