import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val s = sc.next
  val t = sc.next

  val res =
    (if(s(0) == t(0)) 1 else 0) +
      (if(s(1) == t(1)) 1 else 0) +
      (if(s(2) == t(2)) 1 else 0)

  println(res)
}