'use strict';

function main(stdin) {
  const input = stdin.split('\n');
  const S = input[0];
  const T = input[1];

  let ans = 0;
  
  for (let i = 0; i < 3; ++i) {
    if (S[i] === T[i]) ++ans;
  }
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim());