const main = input =>{

    const arr = input.split("\n");
    const yohou = arr[0].split("");
    const real = arr[1].split("");
    var result = 0;
    for(var i=0; i<3; i++){
        if(yohou[i] === real[i]){
            result ++;
        }
    }
    
    console.log(result);
};
main(require('fs').readFileSync('/dev/stdin', 'utf8'));