function Main(input){
var S = input.split("\n")[0].split("");
var T = input.split("\n")[1].split("");
  var count = 0;
for(i=0;i<=2;i++){
  var j = S[i] == T[i];
  if(j==true){
    count += 1;
  }
}
console.log(count);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));