fun main() {
    val (n, k) = readLine()?.split(" ")?.map(String::toInt) ?: return
    val s = Array(n + 1) { 0 }
    repeat(k) {
        val d = readLine()?.toInt() ?: return
        val a = readLine()?.split(" ")?.map(String::toInt) ?: return
        0.until(d).forEach { i ->
            s[a[i]] += 1
        }
    }
    println((s.count { it == 0 } - 1).toString())
}