function Main(input) {
	input = input.trim();
  input = input.split("\n");
  var output = 0;
  for(var i = 0; i < 3; i++){
    var tmp1 = input[0].slice(i,i+1);
    var tmp2 = input[1].slice(i,i+1);
    if(tmp1 == tmp2){
       output++
       }
  }
  console.log(output);
}

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