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