import scala.io.StdIn
object Main extends App {
  val S = StdIn.readLine().toList
  val T = StdIn.readLine().toList
  val list = for {
    i <- 0 until 3
    s = S(i)
    t = T(i)
    if (s == t)
  } yield (s,t)
  println(list.length)
}
