"use strict";
const Main = (input) =>{
   let xs = input.trim().split('\n');
   let a = xs[0].split(''); 
   let b = xs[1].split('');
   let ans = 0;
   for(let i =0; i < 3; i++){
   	if(a[i] == b[i]){
     	ans += 1;
    }
   }
   console.log(ans);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));