import java.util.Scanner;
fun main(args: Array<String>) {
  var sc=Scanner(System.`in`)
  var s=sc.next()
  var t=sc.next()
  var i=0
  var c=0
  while(i<3){
    if(s[i]==t[i]){
      c++
    }
    i++
  }
  println(c)
}