fun main(args:Array<String>) {
    val (person, food) = readLine()!!.split(" ").map { it.toInt() }
    var flag = (1..food).toMutableSet()
    (1..person).forEach {
        val like = readLine()!!.split(" ").map { it.toInt() }.drop(1).toSet()
        flag = flag.filter { a-> like.contains(a) }.toMutableSet()
    }
    println(flag.size)
}
