import java.util.*

object MainKt {
    @JvmStatic
    fun main(args: Array<String>) {
        val scanner = Scanner(System.`in`)
        val n = scanner.nextInt()
        val m = scanner.nextInt()

        val arr = BooleanArray(m){true}

        for (i in 0..n-1){
            val tmp = BooleanArray(m){false}
            val k = scanner.nextInt()
            for (j in 0..k-1){
                val a = scanner.nextInt()
                tmp[a-1] = true
            }
            for (j in 0..m-1){
                arr[j] = arr[j] && tmp[j]
            }
        }

        var ans = 0
        arr.forEach { if(it) ans++ }
        println(ans)

    }
}