#天気予報 S晴れ,C曇り,R雨
S = gets.chomp.split("").map(&:to_s)
#実際の天気 S晴れ,C曇り,R雨
T = gets.chomp.split("").map(&:to_s)
tenkicount = 0
(0..2).each do |n|
    if S[n] == T[n]
        tenkicount += 1
    end
end
puts tenkicount