import java.util.*;

fun main(args: Array<String>) = with(Scanner(System.`in`)) {
	var s = next();
  	var t = next();
  	var ans = 0;
    for (i in 0..2) {
     if (s[i] == t[i]) ans++; 
    }
  	println(ans);
}