function main(input) {
  var expect = input.split('\n')[0];
  var actual = input.split('\n')[1];

  var count = 0;
  for(var i=0; i<3; i++){
    if(expect[i] === actual[i]){
      count++;
    }
  }
  console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));