const Main = (input) => {
const dataArray = input.split('\n');
const forecast = dataArray[0];
const weather = dataArray[1];
var hit = 0;
  for(var i = 0; i < 3; i++){
  	if(forecast[i] == weather[i]){
      hit += 1;
    }
  }
  console.log(hit);
}

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