s = []
t = []
s = gets.chomp.gsub(/S/, "1").gsub(/C/, "2").gsub(/R/, "3").split("").map(&:to_i)
t = gets.chomp.gsub(/S/, "1").gsub(/C/, "2").gsub(/R/, "3").split("").map(&:to_i)
results = 0
3.times do |i|
  if s[i] == t[i]
    results+=1
  end
end
puts results
