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