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