object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val ls = in.map(_.split(' ').map(_.toInt).toArray).tail
  val N = ls.size
  val bin = (0 to 100).map(_ => 0).toArray
  ls.map(_.tail).flatten.foreach{e => bin(e) += 1}
  //println(bin.toSeq)
  //println(N)
  val ret = bin.count(_ == N)
  println(ret)
}
