object Main extends App {
  val in: List[List[Int]] = io.Source.stdin.getLines.map(_.split(" ").toList.map(_.toInt)).toList
  val src: List[List[Int]] = in.filter(in.indexOf(_) % 2 != 0)

  def myLinearSearch(li: List[Int], n: Int): Option[Int] = li match {
    case Nil => None
    case h :: tail => if (h == n) Some(h) else myLinearSearch(tail, n)
  }

  println((for (n <- src(1)) yield myLinearSearch(src(0), n)).filter(_ != None).length)

}