fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main(args: Array<String>) {
    val (n, m) = intList()
    val map = hashMapOf<Int, Int>()
    repeat(n) {
        intList().drop(1).forEach { i ->
            map[i] = map[i]?.let { it + 1 } ?: 1
        }
    }
    println(map.values.count { it == n }.toString())
}