fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    val foods = IntArray(m)
    (1..n).forEach {
        readLine()!!.split(' ').drop(1).forEach { foods[it.toInt() - 1]++ }
    }
    println(foods.filter { it == n } .count())
}
