object Main extends App{
  val firstLine = readLine.split(" ").map(_.toInt)
  val N = firstLine(0)
  def checkNextLine(acc: Array[String], remainingCount: Int): Array[String] = {
    if (remainingCount == 0 || acc.size == 0) {
      return acc
    }
    val nextLikes = readLine.split(" ").tail
    checkNextLine(acc.filter(l => nextLikes.contains(l)), remainingCount - 1)
  }
  
  println(checkNextLine(readLine.split(" ").tail, N - 1).size)
}