object Main {
  def main(args: Array[String]): Unit ={
    val sc = new java.util.Scanner(System.in)
    val s = sc.nextLine()
    val t = sc.nextLine()

    var cnt = 0
    for(i <- 0 to 2){
      if(s.charAt(i) == t.charAt(i)) cnt+=1
    }

    println(cnt)
  }
}