"use strict"

function Main(input) {
  input = input.trim().split('\n');
  const s = input[0];
  const t = input[1];

  let ret = 0;
  if(s[0] === t[0]) ret++;
  if(s[1] === t[1]) ret++;
  if(s[2] === t[2]) ret++;
  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));