"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0].split("");
    const T = arg[1].split("");
    
    let answer = 0;
    
    if(S[0] === T[0]) {
        answer++;
    }
    
    if(S[1] === T[1]) {
        answer++;
    }
    
    if(S[2] === T[2]) {
        answer++;
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));