fun main(args: Array<String>) {
    var (N,M) = readLine()!!.split(" ").map(String::toInt)
    var arr = Array(M,{0})
    (0..N-1).map{i->
        var input = readLine()!!.split(" ").map{x->x.toInt()}
        (1..input.size-1).map{ j->
            arr[input[j]-1] += 1
        }
    }
    var c = 0
    arr.map{x -> if(x == N) c++ }
    println(c)
}
