import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  
  val n = sc.nextInt()
  val m = sc.nextInt()
  
  val counts = new Array[Int](m)
  
  for (i <- 1 to n) {
    val k = sc.nextInt()
    for (j <- 1 to k) {
      counts(sc.nextInt() - 1) += 1
    }
  }
  
  println {
    counts.count(_ == n)
  }
}