import scala.collection.mutable.{HashMap => MMap}
object Main{
  def main(args:Array[String]):Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val m = sc.nextInt
    val map : MMap[Int,Int] = MMap.empty
    for(i <- 1 to n){
      val k = sc.nextInt
      for(j <- 1 to k){
        val like = sc.nextInt
        val count = map.getOrElse(like,0)
        map.put(like, count+1)
      }
    }

    println(map.values.count(_ == n))

  }
}