Problem:
 Score : 200 points    Problem Statement N  Snukes called Snuke 1 , Snuke 2 , ..., Snuke N live in a town.  There are K kinds of snacks sold in this town, called Snack 1 , Snack 2 , ..., Snack K . The following d_i Snukes have Snack i : Snuke A_{i, 1}, A_{i, 2}, \cdots, A_{i, {d_i}} .  Takahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?      Constraints  All values in input are integers.  1 \leq N \leq 100  1 \leq K \leq 100  1 \leq d_i \leq N  1 \leq A_{i, 1} < \cdots < A_{i, d_i} \leq N         Input Input is given from Standard Input in the following format:  N  K  d_1  A_{1, 1} \cdots A_{1, d_1}  \vdots  d_K  A_{K, 1} \cdots A_{K, d_K}       Output Print the answer.        Sample Input 1 3 2
2
1 3
1
3      Sample Output 1 1   Snuke 1 has Snack 1 .  Snuke 2 has no snacks.  Snuke 3 has Snack 1 and 2 .   Thus, there will be one victim: Snuke 2 .       Sample Input 2 3 3
1
3
1
3
1
3      Sample Output 2 2

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10**6)
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K, A):
    b = [0] * N
    for a in A:
        for i in a:
            b[i-1] += 1
    return b.count(0)


def main():
    N, K = read_int_n()
    A = []
    for _ in range(K):
        read_int()
        A.append(read_int_n())
    print(slv(N, K, A))


if __name__ == '__main__':
    main()

Solution (Python):
import bisect,sys
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac =fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV
        
    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s+=a
        yield s


sys.setrecursionlimit(200005)


def main():
    N,K = isRaw()
    sRa = []
    for k in range(K):
        d = iRaw()
        As = isRaw()
        sRa+=As
    return N - len(set(sRa))
    
if __name__ == "__main__":
    print(main())

Solution (Python):
N, K = map(int, input().split())
ans = [0] * N
for i in range(K):
    d = int(input())
    Alist = list(map(int, input().split()))
    for a in Alist:
        ans[a-1] += 1
c = 0
for i in range(N):
    if ans[i] == 0:
        c += 1
print(c)

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

c = Counter()
N, K = map(int, input().split())
for k in range(K):
    d = int(input())
    As = list(map(int, input().split()))
    for a in As: c[a] += 1
print(N - len(c))

Solution (Python):
N, K = map(int, input().split())

check = [1] * (N + 1)
check[0] = 0

for k in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        check[a] = 0


print (sum(check))

Solution (Python):
N, K = map(int, input().split())
T = [1]*N
for _ in range(K):
  input()
  for a in map(int, input().split()):
    T[a-1] = 0
print(sum(T))

Solution (Python):
from collections import Counter

N,K = map(int,input().split())
SNUKE = [0]*N
for i in range(K):
    d = int(input())
    for a in map(int,input().split()):
        a -= 1
        SNUKE[a] += 1

print(Counter(SNUKE)[0])

Solution (Python):
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

n,k = NextInts()
st = set()
for i in range(k):
    d = NextInt()
    da = NextIntList()
    for i in da: st.add(i)
print(n-len(st))

Solution (Python):
N,K = map(int,input().split())
data = [0]*N
for i in range(K):
    di = int(input())
    ai = list(map(int,input().split()))
    for j in range(di):
        data[ai[j]-1] += 1

cnt = 0
for i in range(N):
    if data[i] == 0: cnt += 1

print(cnt)

Solution (Python):
n, k = [int(i) for i in input().split()]
a = set()
for _ in range(k):
    d = int(input())
    aa = [int(i) for i in input().split()]
    a |= set(aa)
print(n-len(a))

Solution (Python):
N,K = map(int,input().split())
lst = list(range(1,N+1))
for i in range(K):
    d = int(input())
    A = map(int,input().split())
    for A_ in A:
        if A_ in lst:
            lst.remove(A_)
print(len(lst))

Solution (Python):
N, D = map(int, input().split())
none = set(range(1, N+1))
for _ in range(D):
  input()
  none -= set(map(int, input().split()))
print(len(none))

Solution (Python):
n, k = map(int, input().split())
ask = set()

for _ in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for i in a:
        ask.add(i)
print(n - len(ask))

Solution (Python):
n, k = map(int, input().split())
s = set()
for _ in range(k):
    d = int(input())
    A = list(map(int, input().split()))
    s |= set(A)

print(n-len(s))

Solution (Python):
import sys
import math  
import bisect  
import queue  


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, K = map(int, input().split())

    res = set()
    for _ in range(K):
        _ = int(input())
        A = list(map(int, input().split()))
        for a in A:
            res.add(a)

    ans = 0
    for i in range(1, N + 1):
        if i not in res:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
n,k = map(int,input().split())
cnt = [0]*n
for i in range(k):
  d = int(input())
  a = list(map(int,input().split()))
  for j in a:
    cnt[j-1] += 1
print(cnt.count(0))

Solution (Python):
N,K = map(int,input().split())
have = [False]*N
for _ in range(K):
    d = int(input())
    ad = list(map(int,input().split()))
    for i in ad:
        have[i-1] = True
ans = N - sum(have)
print(ans)

Solution (Python):
N, K = map(int, input().split())
useds = [0] * N
for _ in range(K):
    d = int(input())
    As = list(map(int, input().split()))
    for A in As:
        useds[A-1] = 1

ans = useds.count(0)
print(ans)

Solution (Python):
N, K = map(int, input().split())
snukes = []

for k in range(K):
    d = int(input())
    a = list(map(int, input().split()))
    snukes += a

print(N - len(set(snukes)))

Solution (Python):
n,k=[int(i) for i in input().split()]
a=[0]*n

for i in range(k):
    d=int(input())
    motteru=[int(i) for i in input().split()]
    for j in motteru:
        a[j-1]+=1
print(a.count(0))

Solution (Python):
n, k = map(int,input().split())

l = [0] * n
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in a:
        l[j - 1] = 1
print(n - sum(l))

Solution (Python):
n, k = map(int, input().split())

okashi = [0 for _ in range(n)]
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in range(d):
        okashi[a[j]-1] += 1
print(okashi.count(0))

Solution (Python):
from collections import Counter


def solve():
    n, k = map(int, input().split())
    l = [0 for _ in range(n)]
    for _ in range(k):
        input()
        a = list(map(int, input().split()))
        for i in a:
            l[i-1] += 1
    c = Counter(l)
    print(c[0])


if __name__ == '__main__':
    solve()

Solution (Python):
n,k = map(int, input().split())
s = set(range(1,n+1))

for _ in range(k):
    d = int(input())
    for a in list(map(int, input().split())):
        if a in s:
            s.remove(a)
print(len(s))

Solution (Python):
n,k = map(int,input().split())
ans = set()
for i in range(k):
    d = input()
    a = set(map(int,input().split()))
    ans = ans|a

print(n - len(ans))

Solution (Python):

def inputlist(): return [int(k) for k in input().split()]

N,K = inputlist()
dic = {n:0 for n in range(1,N+1)}

for i in range(K):
    d = int(input())
    A = inputlist()
    for j in range(d):
        dic[A[j]] +=1
ans= 0
for i in range(1,N+1):
    if dic[i] == 0:
        ans +=1
print(ans)

Solution (Python):
n, k = map(int, input().split())
r = [0 for _ in range(n)]
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in a:
        r[j-1] += 1
result = 0
for i in r:
    if i==0:
        result += 1
print(result)

Solution (Python):
import sys
input=lambda: sys.stdin.readline().rstrip()
n,k=map(int,input().split())
C=[0]*n
for _ in range(k):
  d=int(input())
  A=[int(i) for i in input().split()]
  for a in A:
    C[a-1]+=1
ans=0
for c in C:
  if c==0:
    ans+=1
print(ans)

Solution (Python):
def main():
    N, K = map(int, input().split())

    candy = [0] * N
    for _ in range(K):
        d = int(input())
        *a, = (int(x) - 1 for x in input().split())
        for x in a:
            candy[x] += 1

    print(candy.count(0))


if __name__ == '__main__':
    main()

Solution (Python):
n, k = map(int, input().split())

have = [False] * n
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in a:
        have[j-1] = True

count = 0
for i in range(n):
    if not have[i]:
        count += 1
print(count)

Solution (Python):
N, K = map(int,input().split())
S = [0]*N
for _ in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for e in A:
        S[e-1] = 1
print(S.count(0))

Solution (Python):
N, K = map(int, input().split())
li = [False]*N
for i in range(K):
    d = int(input())
    l = list(map(int, input().split()))
    for x in l:
        li[x-1] = True
ans = 0
for i in range(N):
    if not li[i]:
        ans += 1
        
print(ans)

Solution (Python):
N, K = map(int, input().split())
ct = [0] * N
for _ in range(K):
    d = int(input())
    As = list(map(int, input().split()))
    for a in As:
        ct[a-1] += 1
ans = 0
for c in ct:
    if c == 0:
        ans += 1
print(ans)

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,k = iim()
l = [True]*n
for i in range(k):
    d = ii()
    A = iil()
    for item in A:
        if l[item-1] == True:
            l[item-1] = False

print(l.count(True))

Solution (Python):

N, K = map(int, input().split())
A = [0 for _ in range(N)]
ans = 0
for i in range(K):
    d = int(input())
    tmp = list(map(int, input().split()))
    for j in range(d):
        A[tmp[j]-1] += 1
for i in range(N):
    if A[i] == 0:
        ans += 1
print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

ans = set(range(1, N+1))
for _ in range(K):
	d = INT()
	A = LIST()
	ans -= set(A)
print(len(ans))

Solution (Python):
n, k = map(int, input().split())

has = [0] * n
for _ in range(k):
    d = int(input())
    a = list(map(int, input().split()))

    for aa in a:
        has[aa - 1] = 1

print(n - sum(has))

Solution (Python):
N, K = list(map(int, input().split()))
A = []
for i in range(K):
  d = input()
  A.append(list(map(int, input().split())))

L = [0] * N

for i in A:
  for j in i:
    L[j - 1] = 1

ans = 0
for i in L:
  if i == 0:
    ans += 1

print(ans)

Solution (Python):

N,K=[int(i) for i in input().split(" ")]
sunuke=[0 for i in range(N)]
for i in range(K):
    d=int(input())
    A=[int(j) for j in input().split(" ")]
    for a in A:
        sunuke[a-1]+=1

retval=0
for s in sunuke:
    if s==0:
        retval+=1
print(retval)

Solution (Python):
from sys import stdin
from sys import setrecursionlimit

setrecursionlimit(10 ** 7)

n,k = map(int,stdin.readline().rstrip().split())
se = set()
for i in range(k):
    d = int(stdin.readline().rstrip())
    a = list(map(int,stdin.readline().rstrip().split()))
    for j in a:
        se.add(j)

print(n-len(se))

Solution (Python):
n, k = map(int, input().split())

my_set = set()

for i in range(k):
    _ = int(input())
    my_list = list(map(int, input().split()))
    for item in my_list:
        my_set.add(item)

print(n - len(my_set))

Solution (Python):
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, K = map(int, input().split())
    D = [1] * (N + 1)
    D[0] = 0
    for _ in range(K):
        d = int(input())
        A = list(map(int, input().split()))
        for a in A:
            D[a] = 0
    print(sum(D))


if __name__ == "__main__":
    main()

Solution (Python):
N,K=map(int,input().split())

chk=[0 for _ in range(N)]

for i in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    for j in range(d):
        a=A[j]-1
        chk[a]=1

ans=0
for i in range(N):
    if chk[i]==0:
        ans+=1

print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, K = map(int, rl().split())
    
    su_set = set()
    for _ in range(K):
        d = int(rl())
        ai = list(map(int, rl().split()))
        for aij in ai:
            su_set.add(aij)
    
    print(N - len(su_set))


if __name__ == '__main__':
    solve()

Solution (Python):
n, k = map(int, input().split())
cnt = [0] * (n+1)

for _ in range(k):
    d = int(input())
    a = map(int, input().split())
    for a_i in a:
        cnt[a_i] += 1

ans = 0
for i in cnt:
    if i == 0:
        ans += 1

print(ans-1)

Solution (Python):
n,m = map(int,input().split())
have = [0 for _ in range(n)]
for _ in range(m):
  d = int(input())
  a = list(map(int,input().split()))
  for x in a:
    have[x-1] = 1
print(n-sum(have))

Solution (Python):
n, k = map(int, input().split())
have = [False] * n
for i in range(k):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        have[a-1] = True

print(sum([have[i] == False for i in range(n)]))

Solution (Python):
n,k=map(int,input().split())
l=[1]*n
for i in range(k):
  d=int(input())
  a=list(map(int,input().split()))
  for j in range(d):
    l[a[j]-1]=0
print(sum(l))

Solution (Python):
n, k = map(int, input().split())
sunuke = [0] * n
for i in range(k):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        sunuke[a - 1] += 1

print(len([s for s in sunuke if s == 0]))

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, input().split())
T = set()

for _ in range(K):
    d = int(input())
    A = set(map(int, input().split()))
    T |= A

print(N - len(T))

Solution (Python):
N,K = map(int,input().split())
a = [False for i in range(N)]
for i in range(K):
	d = int(input())
	A = list(map(int,input().split()))
	for x in A:
		a[x-1] = True
print(sum([0 if x else 1 for x in a]))

Solution (Python):
n, k = list(map(int, input().split()))
a = [0] * n
for i in range(k):
    _ = input()
    aa = list(map(int, input().split()))
    for aaa in aa:
        a[aaa - 1] += 1
s = 0
for i in range(n):
    if a[i] == 0:
        s+=1
print(s)

Solution (Python):
N,K = map(int,input().split())
snuke = [0]*N
for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for j in range(d):
        snuke[A[j]-1] += 1
print(snuke.count(0))

Solution (Python):
n, k = map(int, input().split())
l = [0 for _ in range(n)]
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in a:
        l[j - 1] += 1
ans = 0
for i in l:
    if i == 0:
        ans += 1
        
print(ans)

Solution (Python):
N,K = map(int,input().split())

det = [1] * N

for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for x in A:
        x -= 1
        det[x] = 0

print(sum(det))

Solution (Python):
n,k = map(int,input().split())
a = set()
for i in range(k):
    d = int(input())
    p = list(map(int,input().split()))
    for x in p:a.add(x)
print(n-len(a))

Solution (Python):
N, K = map(int, input().split())

done = set([])
for _ in range(K) :
  d = int(input())
  A = [int(i) for i in input().split()]
  done |= set(A)
  
print(N - len(done))

Solution (Python):
n,k = map(int, input().split())
data = []
kind = set(range(1,n+1))
for i in range(k):
    d = int(input())
    li = list(map(int, input().split()))
    for j in li:
        if j in kind:
            kind.remove(j)
print(len(kind))

Solution (Python):
N, K = map(int, input().split())
x = [0] * N
for _ in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        x[a-1] += 1
ans = 0
for y in x:
    if y == 0:
        ans += 1
print(ans)

Solution (Python):
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))


def main():
	N, K = getlist()
	D = defaultdict(int)
	for i in range(K):
		d = int(input())
		A = getlist()
		for j in A:
			D[j] += 1

	ans = N - len(D)
	print(ans)

if __name__ == '__main__':
	main()

Solution (Python):
n,k=map(int,input().split())
count = [0]*n
for _ in range(k):
    d = input()
    a = map(int,input().split())
    for ai in a:
        count[ai-1] += 1

print(sum(x==0 for x in count))

Solution (Python):
n,k=map(int,input().split())
p=[1]*n
for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for g in range(d):
        p[a[g]-1]=0

print(sum(p))

Solution (Python):
n,k = map(int,input().split())

from collections import defaultdict
dic = defaultdict(int)


for _ in range(k):
    d = int(input())
    al = list(map(int,input().split()))
    for a in al:
        dic[a] += 1
ans = 0
for i in range(1,n+1):
    if dic[i] == 0:
        ans += 1
print(ans)

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,k = na()
s = set()

for i in range(k):
    d = ni()
    a = na()
    for j in a:
        s.add(j)

print(n-len(s))

Solution (Python):

import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def main():
    N, K = map(int, input().split())
    snuke = [0]*N
    for k in range(K):
        d = int(input())
        A = list(map(int, input().split()))
        for a in A:
            snuke[a-1] += 1

    cnt = 0
    for s in snuke:
        if s == 0:
            cnt += 1
    print(cnt)

    return


if __name__ == '__main__':
    main()

Solution (Python):
from statistics import median


from fractions import gcd
from itertools import combinations 
from collections import deque
from collections import defaultdict
import bisect










import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,k = readInts()
    LIST = [0] * n
    for i in range(k):
        d = int(input())
        A = readInts()
        for i in range(d):
            LIST[A[i]-1] = 1
    cnt = 0
    for i in range(n):
        if LIST[i] == 0:
            cnt += 1
    print(cnt)
if __name__ == '__main__':
  main()

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n,k = m()

po = [0 for i in range(n)]

for i in range(k):
    d = onem()
    a = l()
    for j in a:
        po[j-1] += 1

co = 0

for i in range(n):
    if po[i] == 0:
        co += 1
print(co)

Solution (Python):
n,k = list(map(int,input().split()))

l = [0]*n
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in a:
        l[j-1]+=1

print(l.count(0))

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, k = LI()
flg = [False]*n
for i in range(k):
    d = I()
    a = LI()
    for j in a:
        flg[j-1] = True
ans = 0
for i in range(n):
    if not flg[i]:
        ans += 1
print(ans)

Solution (Python):
n,k=map(int,input().split())
ans=[0 for i in range(n)]

for i in range(k):
  d=int(input())
  a=list(map(int,input().split()))
  for j in a:
    j-=1
    ans[j]+=1

print(ans.count(0))

Solution (Python):
N, K = map(int, input().split())
C = [0 for _ in range(N)]


for _ in range(K):
    D = int(input())
    A = list(map(int, input().split()))
    for a in A:
        C[a - 1] += 1

res = 0
for c in C:
    if c > 0:
        res += 1

print(N - res)

Solution (Python):
N,K=map(int,input().split())

aset=set()
for i in range(K):
  d=int(input())
  alist=list(map(int,input().split()))
  for a in alist:
    aset.add(a)
    
print(N-len(aset))

Solution (Python):
N,K = map(int,input().split())
Snuke=[0]*N
for _ in range(K):
    d=int(input())
    L = list(map(int,input().split()))
    for l in L:
        Snuke[l-1]+=1

ans=0
for s in Snuke:
    if s==0:
        ans+=1
print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, K = map(int, input().split())
    ans = [0] * N
    for _ in range(K):
        d = int(input())
        A = tuple(map(int, input().split()))
        for a in A:
            ans[a - 1] += 1
    print(len([a for a in ans if a == 0]))

if __name__ == '__main__':
    main()

Solution (Python):
N,K = [int(i) for i in input().split()]
can = [0]*N
for _ in range(K):
    d = int(input())
    A = [int(i) for i in input().split()]
    for a in A:
        can[a-1] += 1
print(can.count(0))

Solution (Python):
N,K=map(int,input().split())
snuke=[0 for i in range(0,N)]
for i in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    for j in range(d):
        snuke[A[j]-1]+=1

ans=0
for i in range(N):
    if snuke[i]==0:
        ans+=1
print(ans)

Solution (Python):
N, K = map(int, input().split())
x = [True] * (N + 1)
for _ in range(K):
    d = int(input())
    a = list(map(int, input().split()))
    for v in a:
        x[v] = False

print(sum(x[1:]))

Solution (Python):
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
S = set()
for _ in range(K):
    D = int(input())
    A = list(map(int, input().split()))
    for a in A:
        S.add(a)

print(N-len(S))

Solution (Python):
N, K = map(int, input().split())
snuke = [1] * (N + 1)
for _ in range(K):
    d = int(input())
    for a in map(int, input().split()):
        snuke[a] = 0
print(sum(snuke[1:]))

Solution (Python):
n,k = map(int, input().split())
ans = set()

for i in range(k):
    d = input()
    a = list(map(int,input().split()))
    for x in a:
        ans.add(x)
print(n-len(ans))

Solution (Python):
N, K = map(int, input().split())
used = [False]*N
for i in range(K):
  d = input()
  s = [int(c) for c in input().split()]
  for c in s:
    used[c-1]=True
print(N-sum(c for c in used))

Solution (Python):
N, K = map(int, input().split())
a = [1 for _ in range(N+1)]
for i in range(K):
    d = int(input())
    l = list(map(int, input().split()))
    for e in l:
        a[e] = 0
print(sum(a[1:]))

Solution (Python):
N, K = map(int, input().split())
F = [1 for _ in range(N)]
for _ in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        F[a - 1] = 0
print(sum(F))

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,k=MI()
    aa=set()
    for _ in range(k):
        II()
        for a in LI():aa.add(a)
    print(n-len(aa))

main()

Solution (Python):
import math
import sys
def mips():
    return map(int,input().split())
def msps():
    return map(str,input().split())
N,K = mips()
res = set()
for i in range(K):
    d = int(input())
    L = [el for el in mips()]
    for el in L:
        res.add(el)
print(N-len(res))

Solution (Python):
N,K = map(int,input().split())
snuke = [0]*N
for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))

    for j in A:
        snuke[j-1] += 1
cnt = 0
for i in snuke:
    if i == 0:
        cnt += 1

print(cnt)

Solution (Python):
n, k = map(int, input().split())

cnt = [0] * (n + 1)
for _ in range(k):
    d = int(input())
    a = tuple(map(int, input().split()))
    for ai in a:
        cnt[ai] += 1

ans = 0
for i in range(1, n + 1):
    if cnt[i] == 0:
        ans += 1
print(ans)

Solution (Python):
N, K = map(int, input().split())
have = [False] * N
for _ in range(K):
    d = int(input())
    for a in map(int, input().split()):
        have[a-1] = True
print(N - sum(have))

Solution (Python):
N, K = map(int, input().split())
ans = [1]*N
for _ in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for a in A:
    ans[a-1] = 0
print(sum(ans))

Solution (Python):
n, k = map(int, input().split())
key = [1]*n
for i in range(k):
  d = int(input())
  a = [int(x) for x in input().split()]
  for v in a:
    key[v-1] = 0
print(sum(key))

Solution (Python):
n,k=map(int,input().split())
ch=[0 for i in range(n)]
for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for j in range(d):
        ch[a[j]-1]+=1

ans=0
for i in range(n):
    if ch[i]==0:
        ans+=1

print(ans)

Solution (Python):
N, K=map(int, input().split())
s=[0]+[1]*N
for i in range(K):
    d=int(input())
    tmp=list(map(int, input().split()))
    for j in tmp:
        s[j]=0
print(sum(s))

Solution (Python):
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
s = set()
for _ in range(K):
  input()
  a = set(map(int, input().split()))
  s |= a
print(N - len(s))

Solution (Python):
n, k = map(int, input().split())

snuke = [0 for i in range(n)]

for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in a:
        snuke[j - 1] += 1

ans = 0
for i in snuke:
    if i == 0:
        ans += 1

print(ans)

Solution (Python):
n,k=map(int,input().split())
ans=[1]*n
for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for j in range(d):
        ans[a[j]-1]=0
print(sum(ans))

Solution (Python):
MOD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)

def main():
    N,K = map(int,input().split())
    atack = [1] * N
    for  i in range(K):
        d = int(input())
        A = list(map(int,input().split()))
        for k in A:
            atack[k - 1] = 0
    print(sum(atack))
    
if __name__ == '__main__':
    main()

Solution (Python):
n, k = map(int, input().split())

set_ = set()
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in range(d):
        set_.add(a[j])
print(n - len(set_))

Solution (Python):
n,k=map(int,input().split())
se=set(list(range(1,n+1)))
for _ in range(k):
  d=int(input())
  *a,=map(int,input().split())
  se=se-set(a)
print(len(se))

Solution (Python):
N,K=map(int,input().split())
r=[1]*N
for k in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    for a in A:
        r[a-1]=0
print(sum(r))

Solution (Python):
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def input():
    return stdin.readline()[:-1]

def main():
    from builtins import int, map
    N, K = map(int, input().split())
    count = [0] * (N + 1)
    for _ in range(K):
        di = int(input())
        Ai = list(map(int, input().split()))
        for a in Ai:
            count[a] += 1
    ans = 0
    
    for v in count[1:]:
        if v == 0:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N, K = map(int, input().split())

A = [False for _ in range(N)]

for _ in range(K):
    _ = input()

    for c in map(int, input().split()):
        A[c-1] = True

print(N - sum(A))