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

  def binarySearch(li: List[Int], n: Int): Option[Int] = li match {
    case h :: Nil => if (h == n) Some(n) else None
    case _ => {
      val midIndex = li.length / 2
      val midValue = li(midIndex)
      if (n < midValue) binarySearch(li.take(midIndex), n)
      else if (n > midValue) binarySearch(li.drop(midIndex), n)
      else Some(n)
    }
  }


  println((for (i <- src(1)) yield { binarySearch(src(0), i)}).filter(_ != None).length)
}

