"use strict"

const main = (input) => {
    const _input = input.split("\n");
    const S = _input[0].split("");
    const T = _input[1].split("");
    let count = 0;

    for(let i = 0; i < 3; i++){
        if(S[i] === T[i]){
            count += 1;
        }
    }

    console.log(count);
}

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