function Main(input) {
	var data = input.split("\n")
	var count = 0;
	for(var i = 0; i <= 2; i++){
		if(data[0][i] == data[1][i]) {
			count++;
		}
	}
	console.log(count)
}
 
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));