function Main(input) {
  input = input.split('\n');
  s = input[0].split('');
  t = input[1].split('');
  var n = 0;

  if(s[0] === t[0]){
    n++;
  }
  if(s[1] === t[1]){
    n++;
  }
  if(s[2] === t[2]){
    n++;
  }
  console.log(n);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));