var S = readLine()!
var T = readLine()!
var suuji = 0

for num in 0...2{
  let Sa = S.index(S.startIndex, offsetBy: num)
  let Ta = T.index(T.startIndex, offsetBy: num)
  if S [Sa]==T [Ta] {
    suuji += 1
  }
}
print(suuji)