fun main(args: Array<String>) {
  val (N,M) = readLine()!!.split(" ").map{it.toInt()}
  var m = (1..M).map{it}.toSet()
  val k = (1..N).map{
    readLine()!!.split(" ").map{it.toInt()}.drop(1)
  }
  for(i in 0 until N) {
    m = m.intersect(k.get(i))    
  }
  println(m.size)
}