object Main extends App {
	val Array(n, m) = scala.io.StdIn.readLine.split(" ").map(_.toInt)

	var ans = Set[Int]()

	for(i<-1 to m){
		ans += i
	}

	for(i<-0 until n){
		var sub = scala.io.StdIn.readLine.split(" ").map(_.toInt).tail.toSet
		ans &= sub
	}

	println(ans.size)

}