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