fun main(args:Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val vote = (0..m).map { 0 }.toMutableList()
    for(i in (1..n)) {
        readLine()!!.split(" ").map { it.toInt() }.drop(1).forEach { vote[it]++ }
    }
    println(vote.count { it == n })
}