import scala.math

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  def divisors(n: Int): List[Int] =
    for (i <- (1 to n).toList if n % i == 0) yield i

  var s = sc.next()
  var t = sc.next()
  var ans = 0
  for (i <- 0 until 3){
    if(s(i) == t(i))ans += 1
  }
  println(ans)
}
