predictions_S = gets.chars
predictions_T = gets.chars

hit = 0

if predictions_S[0] == predictions_T[0] then
  hit += 1
end

if predictions_S[1] == predictions_T[1] then
  hit += 1
end

if predictions_S[2] == predictions_T[2] then
  hit += 1
end

puts hit
