function main(arg) {
	arg = arg.trim().split('\n');
	var t = arg[1],
        s = arg[0],
        mac = [],
        out = 0;
  	for (var i = 0; i < 3; i ++) {
    	mac.push(t[i] == s[i] ? true : false);
      	if (mac[i] === true) {
        	out++;
        }
    }
  console.log(out)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));