fun main(arr: Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val inpt = (1..n).map { readLine()!!.split(" ").map { it.toInt() }.drop(1) }
    val ans = (1..m).filter {f-> inpt.all { it.contains(f) } }
    println(ans.size)
}
