fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    val argList = (1..n).map {
        val tmp = readLine()!!.split(' ')
        tmp.subList(1, tmp.lastIndex + 1).map(String::toInt)
    }
    val count = (1..m).filter { num ->
        argList.all { it.contains(num) }
    }.count()
    println(count)
}