const Main = input => {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    var s = input[0].split('\n');
    var t = input[1].split('\n');
    var count = 0;
  	for(var i = 0,i++,i<3){
    	if(s[i] == t[i]){
      		count++;
        }
    }
  console.log(count); 
} 
  Main(require('fs').readFileSync('/dev/stdin', 'utf8'))
