import scala.math._
import scala.annotation._
import scala.collection._
import scala.collection.{mutable => mut}
import scala.util.control.Breaks.{breakable,break}

object Main {
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)

    val n, m = sc.nextInt

    var xs = (1 to m).toSet
    (0 until n).foreach { i =>
      val k = sc.nextInt
      xs = xs intersect List.fill(k)(sc.nextInt).toSet
    }

    println(xs.size)
  }
}