inputs = readlines
# inputs = "SSR\nSSR\n".split("\n")

s = inputs[0]
t = inputs[1]

def solve(s, t)
  count = 0
  (0..2).each do |i|
    count += 1 if s.chars[i] == t.chars[i]
  end
  count
end

puts solve(s, t)

