fun main(args: Array<String>){
    val info = readLine()!!.split(" ")
    var n = Integer.parseInt(info[0])

    var commonFavorites = readLine()!!.split(" ")
    commonFavorites = commonFavorites.drop(1)
    n = n -1
    while(n > 0){
        var favorites = readLine()!!.split(" ")
        favorites = favorites.drop(1)

        var newCommonFavorites = mutableListOf<String>()
        for(f in favorites){
            for(cf in commonFavorites){
                if(cf == f) newCommonFavorites.add(cf)
            }
        }

        commonFavorites = newCommonFavorites
        n = n -1
    }

    println(commonFavorites.size)
}