import scala.collection._

val Array(n, m) = scala.io.StdIn.readLine().split("\\s").map(_.toInt)
var cnt_array = mutable.Seq[Int]()

for (i <- 1 to 31){
    cnt_array :+= 0
}

for (i<-1 to n){
val tmp_array = scala.io.StdIn.readLine().split("\\s").map(_.toInt)
val k = tmp_array.take(1)
val as = tmp_array.drop(1)
  for (j <- 0 until k(0)){
    cnt_array(as(j)) = cnt_array(as(j)) + 1
  }
}

var result = 0
for (i<- cnt_array){
  if (i == n){
    result += 1
  }
}

println(result)