'use strict'

function Main(input) {
  const S = input.split("\n")[0].split("")
  const T = input.split("\n")[1].split("")

  let ans = 0
  for(let i=0; i<3; i++) {
    if(S[i] === T[i]) {
      ans++
    }
  }
  console.log(ans)  
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim())
