object Main extends App {
  val forecast = scala.io.StdIn.readLine.toList
  val actual = scala.io.StdIn.readLine.toList
  val zipped = forecast zip actual
  val answer = zipped count { z => z._1 == z._2 }
  println(answer)
}