AtCoder Beginner Contest 166 - Trick or Treat

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-----
3 2
2
1 3
1
3

-----Sample Output-----
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.

Source: atcoder | Difficulty: EASY


Solutions:
(N, K) = map(int, input().split())
dA = [list(map(int, input().split())) for k in range(2 * K)]
L = list(sum(dA[1::2], []))
print(N - len(set(L)))


(N, K) = list(map(int, input().split()))
table = [0] * N
for _ in range(K):
	num = int(input())
	have_list = list(map(int, input().split()))
	for child in have_list:
		table[child - 1] += 1
print(str(table.count(0)))


(n, k) = map(int, input().split())
s = set(range(1, -~n))
for _ in range(k):
	input()
	s -= set(map(int, input().split()))
print(len(s))


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


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


(N, K) = map(int, input().split())
n = [0] * N
for _ in range(K):
	d = int(input())
	for i in map(int, input().split()):
		n[i - 1] = 1
print(N - sum(n))


(n, k) = map(int, input().split())
s = set()
for _ in range(k):
	tmp = int(input())
	arr = list(map(int, input().split()))
	for a in arr:
		s.add(a)
print(n - len(s))


(N, K) = map(int, input().split())
P = [1 for i in range(N)]
for i in range(K):
	d = int(input())
	a = list(map(int, input().split()))
	for j in a:
		x = j - 1
		P[x] = 0
print(sum(P))


(N, K) = map(int, input().split())
a = set()
for i in range(K):
	input()
	b = set(map(int, input().split()))
	a |= b
print(N - len(a))


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


(n, k) = map(int, input().split())
ans = []
for _ in range(k):
	d = int(input())
	ans += list(map(int, input().split()))
print(n - len(set(ans)))


(s1, s2) = map(int, input().split())
A = set()
for i in range(s2):
	N = input()
	A |= set(map(int, input().split()))
print(s1 - len(A))


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


(N, K) = list(map(int, input().split()))
A = []
for i in range(K):
	d = int(input())
	a = []
	if d > 1:
		a = list(map(int, input().split()))
		A.extend(a)
	else:
		A.append(int(input()))
print(N - len(set(A)))


(n, k) = map(int, input().split())
snukes = []
for _ in range(k):
	okashi = int(input())
	snukes += [int(v) for v in input().split()]
target = 1
cnt = 0
l = list(set(snukes))
s = [int(v) for v in range(1, n + 1)]
for p in s:
	if p not in l:
		cnt += 1
print(cnt)


(n, k) = map(int, input().split())
a = set()
for _ in range(k):
	_ = input()
	a = a | set(input().split())
print(n - len(a))


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


(n, k) = map(int, input().split())
s = set()
for i in range(k):
	input()
	s |= set(input().split())
print(n - len(s))


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


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


(n, k) = map(int, input().split())
(n, c) = (set(range(1, n + 1)), set())
for i in range(k):
	input()
	c |= set(map(int, input().split()))
print(len(n ^ c))


(n, k) = map(int, input().split())
s = set()
for i in range(k):
	d = input()
	a = list(map(int, input().split()))
	s |= set(a)
print(n - len(s))


[N, K] = [int(i) for i in input().split()]
okasi = [0] * N
for k in range(K):
	num = int(input())
	have = [int(i) for i in input().split()]
	for snuke in have:
		okasi[snuke - 1] = num
print(okasi.count(0))


(N, K) = map(int, input().split())
A = []
for i in range(K):
	d = int(input())
	A += list(map(int, input().split()))
print(N - len(set(A)))


radi = input()
list = radi.split(' ')
N = int(list[0])
K = int(list[1])
empty = ''
for items in range(K):
	koyjon = input()
	empty += input() + ' '
new = empty.split()
emp = []
for i in new:
	if i not in emp:
		emp.append(i)
print(N - len(emp))


(n, k) = map(int, input().split())
A = []
for i in range(int(k)):
	d = input()
	A += input().split()
print(n - len(set(A)))


(n, k) = map(int, input().split())
s = [0] * n
for _ in range(k):
	d = int(input())
	a = list(map(int, input().split()))
	for x in a:
		s[x - 1] = 1
print(s.count(0))


(a, b) = map(int, input().split())
w = []
t = {}
for i in range(b):
	c = int(input())
	s = list(map(int, input().split()))
	w += s
t = set(w)
print(a - len(t))


(n, k) = map(int, input().split())
l = []
for i in [0] * k:
	d = input()
	l += list(map(int, input().split()))
print(n - len(set(l)))


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


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


(N, K) = map(int, input().split())
treat = [0] * N
for _ in range(K):
	d = int(input())
	A = list(map(int, input().split()))
	for a in A:
		treat[a - 1] += 1
print(treat.count(0))


(n, k) = map(int, input().split())
a = ''
b = []
for i in range(0, k):
	a = input()
	b += input().split()
c = set(b)
print(n - len(c))


(n, k) = map(int, input().split())
l = []
for i in range(k):
	input()
	l.extend(map(int, input().split()))
print(n - len(set(l)))


(n, k) = map(int, input().split())
a = [0] * (n + 1)
answer = 0
for i in range(k):
	d = int(input())
	b = list(map(int, input().split()))
	for j in range(d):
		a[b[j]] += 1
for q in range(1, n + 1):
	if a[q] == 0:
		answer += 1
print(answer)


f = lambda : map(int, input().split())
(n, k) = f()
s = set()
for _ in range(k):
	input()
	s |= set(f())
print(n - len(s))


(N, K) = map(int, input().split())
s = {i + 1 for i in range(N)}
t = set()
for i in range(K):
	input()
	t |= set(map(int, input().split()))
print(len(s - t))


(N, K) = map(int, input().split())
A = []
for i in range(K):
	d = int(input())
	a = list(map(int, input().split()))
	A.extend(a)
B = set(A)
print(N - len(B))


(N, K) = list(map(int, input().split()))
n = set()
for i in range(K):
	ds = input()
	n = n | set(input().split())
print(N - len(n))


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


(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))


(N, K) = map(int, input().split())
ans = []
for i in range(K):
	_ = input()
	ans += input().split()
print(N - len(set(ans)))


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


(n, k) = map(int, input().split())
st = set()
for i in range(k):
	x = int(input())
	a = set(map(int, input().split()))
	st |= a
print(n - len(st))


(n, k) = [int(i) for i in input().split()]
a = [0 for i in range(n)]
for i in range(k):
	x = input()
	t = [int(i) for i in input().split()]
	for j in t:
		a[j - 1] += 1
ans = 0
for i in a:
	if i == 0:
		ans += 1
print(ans)


(N, K) = map(int, input().split())
tmp = set()
for i in range(K):
	input()
	tmp.update(map(int, input().split()))
print(N - len(tmp))


(N, K) = [int(i) for i in input().split()]
A = []
for i in range(K):
	input()
	A += [int(i) for i in input().split()]
print(N - len(set(A)))


(a, b) = map(int, input().split())
s = set()
for i in range(b):
	p = int(input())
	l = list(map(int, input().split()))
	for j in l:
		s.add(j)
print(a - len(s))


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


(N, K) = map(int, input().split())
count = 0
num_people = []
num_people_snacks = []
for i in range(1, N + 1):
	num_people.append(i)
while K > count:
	d = int(input())
	A = list(map(int, input().split()))
	for k in A:
		num_people_snacks.append(k)
	count += 1
ans = 0
for j in range(N):
	if num_people[j] not in num_people_snacks:
		ans += 1
print(ans)


(n, k) = map(int, input().split())
s = [i for i in range(1, n + 1)]
for _ in range(k):
	d = int(input())
	arr = list(map(int, input().split()))
	for a in arr:
		if a in s:
			s.remove(a)
print(len(s))


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


(N, K) = list(map(int, input().split()))
d = list()
d = [d + list(input().split()) for i in range(K * 2)]
print(N - len(set(sum(d[1::2], []))))


f = lambda : map(int, input().split())
(n, k) = f()
l = [1] * n
for _ in range(k):
	input()
	for i in f():
		l[i - 1] = 0
print(sum(l))


(n, k) = map(int, input().split())
kl = [[] for i in range(k)]
for i in range(k):
	d = int(input())
	a = list(map(int, input().split()))
	for j in range(d):
		kl[i].append(a[j])
safe = 0
for i in range(1, n + 1):
	for j in range(k):
		if i in kl[j]:
			safe += 1
			break
print(n - safe)


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


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


(n, k) = map(int, input().split())
s = set()
for i in range(k):
	a = input()
	bs = input().split()
	for b in bs:
		s.add(b)
print(n - len(s))


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


def main():
	(n, k) = list(map(int, input().split()))
	d = set()
	for i in range(k):
		input()
		d.update(list(map(int, input().split())))
	print(n - len(d))

def __starting_point():
	main()
__starting_point()


(N, K) = map(int, input().split())
d = []
A = []
for i in range(K):
	d.append(int(input()))
	A.append(list(map(int, input().split())))
a = set()
ans = 0
for i in range(K):
	for j in range(len(A[i])):
		a.add(A[i][j])
for i in range(1, N + 1):
	if i not in a:
		ans += 1
print(ans)


(N, K) = [int(n) for n in input().split()]
x = set()
for n in range(K):
	d = input()
	for n in input().split():
		x.add(n)
print(N - len(x))


(N, K) = map(int, input().split())
S = set()
for _ in range(K):
	d = int(input())
	S |= set(input().split())
print(N - len(S))


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


(N, K) = map(int, input().split())
x = [0] * (N + 1)
for i in range(K):
	d = int(input())
	if d > 0:
		a = list(map(int, input().split()))
		for v in a:
			x[v] += 1
c = 0
for i in range(1, N + 1, 1):
	if x[i] == 0:
		c += 1
print(c)


whatMan = []
(N, K) = input().split()
for i in range(int(K)):
	input()
	whatMan.extend(input().split())
print(int(N) - len(set(whatMan)))


(n, k) = list(map(int, input().split()))
s = []
for i in range(k):
	d = int(input())
	a = list(map(int, input().split()))
	for i in range(d):
		s.append(a[i])
t = sorted(s)
a = len(t)
x = n
for i in range(n):
	for k in range(a):
		if i + 1 == t[k]:
			x -= 1
			break
		elif i + 1 < t[k]:
			break
print(x)


import itertools
(n, k) = map(int, input().split())
ans = 0
l = []
for i in range(k):
	d = int(input())
	l.append(input().split())
l = list(itertools.chain.from_iterable(l))
l = [int(i) for i in l]
for i in range(1, n + 1):
	if not i in l:
		ans += 1
print(ans)


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


R = lambda : map(int, input().split())
(n, k) = R()
s = set()
for _ in range(k):
	input()
	s.update(R())
print(n - len(s))


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


def main() -> None:
	(n, k) = list(map(int, input().split()))
	check = [0] * n
	for _ in range(k):
		_ = input()
		having = tuple(map(int, input().split()))
		for idx in having:
			check[idx - 1] += 1
	print(check.count(0))
	return

def __starting_point():
	main()
__starting_point()


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


(n, k) = list(map(int, input().split()))
d = [0] * k
A = []
for i in range(k):
	d = int(input())
	A += list(map(int, input().split()))
	list(set(A))
cnt = 0
for i in range(n):
	if i + 1 not in A:
		cnt += 1
print(cnt)


(N, K) = map(int, input().split())
SET = set()
for i in range(K):
	d = map(int, input().split())
	SET |= set(map(int, input().split()))
print(N - len(SET))


(N, K) = map(int, input().split())
A = []
people = list(range(1, N + 1, 1))
for idx in range(K):
	d = int(input())
	X = list(map(int, input().split()))
	for i in range(len(X)):
		A.append(X[i])
ans = [i for i in people if not i in A]
print(len(ans))


import itertools
(N, K) = map(int, input().split())
d = []
A = []
for i in range(K):
	d.append(int(input()))
	A.append(list(map(int, input().split())))
A = list(itertools.chain.from_iterable(A))
count = 0
for i in range(1, N + 1):
	if not i in A:
		count += 1
print(count)


I = lambda : map(int, input().split())
(N, K) = I()
r = [1] * N
for _ in [0] * K:
	I()
	for a in I():
		r[a - 1] = 0
print(sum(r))


(n, k) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(2 * k)]
b = []
for i in range(k):
	b += a[2 * i + 1]
c = set(b)
print(n - len(c))


(n, k) = map(int, input().split())
arr = []
for i in range(k):
	int(input())
	arr += list(map(int, input().split()))
print(n - len(set(arr)))


(n, k) = map(int, input().split())
L = []
for i in range(k):
	d = input()
	l = list(map(int, input().split()))
	L += l
print(n - len(set(L)))


(N, K) = list(map(int, input().split()))
lst = list(range(1, N + 1))
for _ in range(K):
	d = int(input())
	A = list(map(int, input().split()))
	lst = list(set(lst) - set(A))
print(len(lst))


(N, K) = map(int, input().split())
s = set()
for i in range(K):
	d = input()
	l = set(map(int, input().split()))
	s |= l
print(N - len(s))


(n, _, *t) = ''.join([*open(0)][::2]).split()
print(int(n) - len({*t}))


(n, k) = map(int, input().split())
a = set()
for _ in range(k):
	d = input()
	b = set(input().split())
	a = a.union(b)
print(n - len(a))


(n, k) = map(int, input().split())
cnt = [0] * (n + 1)
for j in range(k):
	tmp = int(input())
	arr = list(map(int, input().split()))
	for val in arr:
		cnt[val] += 1
ans = 0
for i in range(1, n + 1):
	if cnt[i] == 0:
		ans += 1
print(ans)


(N, K) = map(int, input().split())
l = []
for _ in range(K):
	int(input())
	l.extend(input().split())
print(N - len(set(l)))


(N, K) = map(int, input().split())
S = []
for i in range(2 * K):
	a = input().split()
	if i % 2 == 1:
		S.extend(a)
print(N - len(set(S)))


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


(n, k) = map(int, input().split())
s = set()
for _ in range(k):
	d = int(input())
	s = s.union(list(map(int, input().split())))
print(n - len(s))


(N, K) = map(int, input().split())
S = set()
for k in range(K):
	input()
	S |= set(input().split())
print(N - len(S))


(N, K) = map(int, input().split())
sunukes = [0 for k in range(N)]
for k in range(K):
	d = int(input())
	A = list(map(int, input().split()))
	for a in A:
		sunukes[a - 1] += 1
	assert len(A) == d
print(len([k for k in sunukes if k == 0]))


(n, k) = map(int, input().split())
l = []
for _ in range(k):
	d = input()
	l.extend(input().split())
uni = set(l)
print(n - len(uni))


(N, K) = list(map(int, input().split()))
num_list = []
for i in range(2 * K):
	num_list.append(list(map(int, input().split())))
list1 = []
s = 0
while s < 2 * K - 1:
	list1.append(num_list[s + 1])
	s = s + 2
list2 = []
for i in range(K):
	x = len(list1[i])
	t = 0
	while t < x:
		list2.append(list1[i][t])
		t = t + 1
z = len(set(list2))
print(N - z)


(N, K) = map(int, input().split())
ans = list()
for i in range(K):
	D = int(input())
	L = list(map(int, input().split()))
	ans += L
	ans = list(set(ans))
print(N - len(ans))


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


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


from collections import defaultdict
(n, k) = map(int, input().split())
m = defaultdict(int)
for _ in range(k):
	input()
	for x in input().split():
		m[int(x)] += 1
result = 0
for i in range(1, n + 1):
	if m[i] == 0:
		result += 1
print(result)


(N, K) = map(int, input().split())
sunuke = [0] * N
for _ in range(K):
	d = int(input())
	temp = list(map(int, input().split()))
	for j in temp:
		sunuke[j - 1] += 1
ans = 0
for k in range(len(sunuke)):
	if sunuke[k] == 0:
		ans += 1
print(ans)


(n, k) = input().split()
h = {}
for i in range(int(n)):
	h[int(i) + 1] = 0
for i in range(int(k)):
	input()
	tmp = input().split()
	for j in tmp:
		h[int(j)] += 1
count = 0
for (i, j) in h.items():
	if j == 0:
		count += 1
print(count)


(N, K) = list(map(int, input().split()))
d = [None] * K
sunuke = [0] * N
A = []
for i in range(K):
	d[i] = int(input())
	A.append(list(map(int, input().split())))
for members in A:
	for member in members:
		sunuke[member - 1] = 1
print(N - sum(sunuke))


(N, K) = (int(x) for x in input().split())
listN = [1] * N
for i in range(K):
	d = int(input())
	tmp = list(map(int, input().split()))
	for j in tmp:
		listN[j - 1] = 0
print(sum(listN))


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


(n, k) = map(int, input().split())
e = []
for i in range(k):
	s = int(input())
	l = list(map(int, input().split()))
	e = e + l
r = set(e)
print(n - len(r))


(n, k) = map(int, input().split())
a = []
d = []
for i in range(k):
	d.append(int(input()))
	a.append(list(map(int, input().split())))
mem = 0
for i in range(1, n + 1):
	check = False
	for j in range(k):
		if i in a[j]:
			check = True
	if not check:
		mem += 1
print(mem)


import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp
INF = inf
MOD = 1000000007
(n, k) = [int(i) for i in input().split()]
d = []
A = []
for i in range(k):
	d.append(int(input()))
	A.append([int(i) for i in input().split()])
tmp = [True for i in range(n + 1)]
res = 0
for i in range(k):
	for j in range(d[i]):
		tmp[A[i][j]] = False
for i in range(1, n + 1):
	if tmp[i]:
		res += 1
print(res)


(N, K) = map(int, input().split())
A = []
for _ in range(K):
	d = int(input())
	A.append(list(map(int, input().split())))
print(N - len(set(sum(A, []))))


(x, *l) = open(0)
print(int(x.split()[0]) - len({*''.join(l[1::2]).split()}))


(N, K) = map(int, input().split())
A = set()
for _ in range(K):
	d = input()
	A = A.union(set(map(int, input().split())))
print(N - len(A))


(N, K) = map(int, input().split())
D = []
A = []
for _ in range(K):
	D.append(int(input()))
	A.append(list(map(int, input().split())))
l = [0] * N
for i in range(K):
	for j in range(D[i]):
		l[A[i][j] - 1] += 1
print(l.count(0))


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


(N, K) = map(int, input().split())
Have = set([])
for _ in range(K):
	_ = input()
	Have |= set(map(int, input().split()))
print(N - len(Have))


(n, k) = map(int, input().split())
l = []
for i in range(1, k + 1):
	dummy = input()
	f = list(input().split())
	l += f
t = len(set(l))
print(n - t)


import collections
(n, k) = map(int, input().split())
sunukes = [0] * n
for i in range(k):
	d = int(input())
	aa = list(map(int, input().split()))
	for a in aa:
		sunukes[a - 1] += 1
c = collections.Counter(sunukes)
ans = c[0]
print(ans)


import itertools
(N, K) = map(int, input().split())
d = []
A = []
for i in range(K):
	d.append(int(input()))
	array = list(map(int, input().strip().split()))
	A.append(array)
X = list(itertools.chain.from_iterable(A))
X = list(set(X))
print(N - len(X))


(N, K) = map(int, input().split())
ha = set()
for i in range(K):
	d = int(input())
	a = set(map(int, input().split()))
	ha = ha | a
print(N - len(ha))


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


(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))


(n, k) = map(int, input().split())
M = set()
for i in range(k):
	d = int(input())
	L = list(map(int, input().split()))
	for i in L:
		M.add(i)
print(n - len(M))


(N, K) = map(int, input().split())
S = set(range(1, N + 1))
for _ in range(K):
	input()
	A = set(map(int, input().split()))
	S -= A
print(len(S))


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


(n, k) = list(map(int, input().split()))
s = set()
for i in range(k):
	int(input())
	j = set(map(int, input().split()))
	s = s.union(j)
print(n - len(s))


(n, k) = map(int, input().split())
d = []
a = []
for i in range(k):
	d.append(int(input()))
	a.append(list(map(int, input().split())))
cnt = 0
for i in range(1, n + 1):
	if i not in set(sum(a, [])):
		cnt += 1
print(cnt)


(n, k) = list(map(int, input().split()))
sunukes = [0 for i in range(n)]
for i in range(k):
	d = int(input())
	aa = list(map(int, input().split()))
	for j in range(d):
		sunukes[aa[j] - 1] += 1
count = sum((1 for sunuke in sunukes if sunuke == 0))
print(count)


(N, K) = map(int, input().split())
A = set()
for _ in range(K):
	d = int(input())
	A.update(list(map(int, input().split())))
print(N - len(A))


(N, K) = map(int, input().split())
n_lis = [0] * N
for i in range(K):
	d = int(input())
	(*A,) = map(int, input().split())
	for j in range(d):
		a = A[j]
		n_lis[a - 1] = 1
print(n_lis.count(0))


from typing import Union, List

def answer(n: int, k: int, da: List[Union[int, List[int]]]) -> int:
	result = set()
	for (d, a) in da:
		result |= set(a)
	return n - len(result)

def main():
	(n, k) = map(int, input().split())
	da = [[int(input()), list(map(int, input().split()))] for _ in range(k)]
	print(answer(n, k, da))

def __starting_point():
	main()
__starting_point()


(N, K) = map(int, input().split())
D = []
A = set()
for i in range(K):
	D.append(int(input()))
	A = A | set(map(int, input().split()))
length = len(A)
print(N - length)


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


(N, K) = map(int, input().split())
sunuke = [1] * N
for i in range(K):
	di = int(input())
	tmp = map(int, input().split())
	for j in tmp:
		sunuke[j - 1] = 0
print(sum(sunuke))


(N, K) = list(map(int, input().split()))
d = []
A = []
for _ in range(K):
	d.append(int(input()))
	A.append(list(map(int, input().split())))
cnt = [0 for i in range(N)]
for i in range(K):
	for a in A[i]:
		cnt[a - 1] += 1
print(cnt.count(0))


(N, K) = map(int, input().split())
l = []
for i in range(K):
	int(input())
	temp = input().split()
	l.extend(temp)
print(N - len(set(l)))


(N, K) = map(int, input().split())
d = []
A = []
for i in range(K):
	p = int(input())
	q = [int(i) for i in input().split()]
	d.append(p)
	A.append(q)
S = [False] * N
for i in range(K):
	for j in range(d[i]):
		S[A[i][j] - 1] = True
print(S.count(False))


(n, k) = map(int, input().split())
d = list()
array = list()
for i in range(k):
	d.extend(input())
	array.extend(input().split())
print(n - len(set(array)))


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


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


(n, k) = list(map(int, input().split()))
a = []
for i in range(k):
	d = int(input())
	ai = list(map(int, input().split()))
	for j in range(d):
		if not ai[j] in a:
			a.append(ai[j])
print(n - len(a))


(N, *D) = open(0)
print(int(N.split()[0]) - len(set(sum([a.split() for a in D[1::2]], []))))


def N():
	return int(input())

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

def NL(n):
	return [list(map(int, input().split())) for i in range(n)]
mod = pow(10, 9) + 7
(n, k) = L()
l = [1] * n
for i in range(k):
	d = N()
	a = L()
	for j in a:
		l[j - 1] = 0
print(l.count(1))


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


(n, k) = map(int, input().split())
a = set()
for i in [0] * k:
	_ = input()
	a = a | set([*map(int, input().split())])
print(n - len(a))


from itertools import chain
a = list(open(0))
n = int(a[0].split()[0])
print(n - len(set(chain.from_iterable(map(str.split, a[2::2])))))


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


(N, K) = list(map(int, input().split()))
dst = [1] * N
for i in range(K):
	d = int(input())
	A = list(map(int, input().split()))
	for j in range(d):
		dst[A[j] - 1] = 0
print(sum(dst))


(N, K) = map(int, input().split())
O = [1] * N
for i in range(K):
	d = int(input())
	for j in map(int, input().split()):
		O[~-j] = 0
print(sum(O))


(N, K) = (int(x) for x in input().split())
A = []
for i in range(K):
	d = int(input())
	a = input()
	A.extend(a.split())
print(N - len(set(A)))


import numpy as np
(n, k) = list(map(int, input().split()))
l = [0 for i 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
print(l.count(0))


(n, k) = list(map(int, input().split()))
A = []
for _ in range(k):
	d = input()
	A.extend(list(map(int, input().split())))
print(n - len(set(A)))


(N, K) = map(int, input().split())
s = set(range(1, N + 1))
for i in range(K):
	d = int(input())
	A = list(map(int, input().split()))
	for x in A:
		try:
			s.remove(x)
		except:
			pass
print(len(s))


(N, K) = [int(x) for x in input().split()]
A = []
for k in range(K):
	d = input()
	A += input().split()
ans = N - len(set(A))
print(ans)


(N, K) = list(map(int, input().split()))
ns = {x for x in range(1, N + 1)}
for _ in range(K):
	_ = input()
	ns -= set(map(int, input().split()))
print(len(ns))


(N, K) = map(int, input().split())
List = [list(map(int, input().split())) for i in range(2 * K)]
a = [List[2 * j + 1] for j in range(K)]
print(N - len(set(sum(a, []))))


(n, k) = [int(x) for x in input().split()]
p = []
for i in range(k):
	d = input()
	p.extend([x for x in input().split()])
p = list(set(p))
print(n - len(p))


(n, k) = list(map(int, input().split()))
s = {i: 0 for i in range(n + 1)}
for i in range(k):
	d = int(input())
	a = list(map(int, input().split()))
	for i in a:
		s[i] += 1
cnt = -1
for i in s:
	if s[i] == 0:
		cnt += 1
print(cnt)


import math

def i_input():
	return int(input())

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

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

def i_row(N):
	return [int(input()) for _ in range(N)]

def i_row_list(N):
	return [list(map(int, input().split())) for _ in range(N)]
(mnum, snum) = i_map()
snholder = set()
for i in range(snum):
	d = i_input()
	ls = i_list()
	snholder = snholder | set(ls)
print(mnum - len(snholder))


(n, k) = map(int, input().split())
snukes = [False] * n
for _ in range(k):
	d = int(input())
	a = list(map(int, input().split()))
	A = [n - 1 for n in a]
	for i in range(d):
		snukes[A[i]] = True
print(snukes.count(False))


def __starting_point():
	(n, k) = list(map(int, input().split()))
	A = [0] * n
	for _ in range(k):
		m = int(input())
		B = list(map(int, input().split()))
		for b in B:
			A[b - 1] += 1
	print(A.count(0))
__starting_point()


(N, K) = map(int, input().split())
S = {*range(1, N + 1)}
for i in range(K):
	_ = input()
	S -= {*map(int, input().split())}
print(len(S))


(N, K) = tuple(map(int, input().split()))
s = set()
for k in range(K):
	input()
	s = s | set(map(int, input().split()))
print(N - len(s))


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


((n, k), *p) = [[*map(int, i.split())] for i in open(0)]
a = sum([p[2 * i + 1] for i in range(k)], [])
print(n - len(set(a)))


(s, value) = map(int, input().split())
li = []
for j in range(s):
	li.append(j + 1)
for i in range(value):
	n = int(input())
	li_s = list(map(int, input().split()))
	for k in range(n):
		if li_s[k] in li:
			li.remove(li_s[k])
print(len(li))


(N, K) = map(int, input().split())
A = set()
for i in range(K):
	_ = input()
	for j in input().split():
		A.add(int(j))
print(N - len(A))


(N, K) = map(int, input().split())
G = 0
S = []
for i in range(K):
	G = int(input())
	S.extend(input().split())
print(N - len(set(S)))


(N, K) = map(int, input().split())
s = set()
for _ in range(K):
	D = int(input())
	s.update(map(int, input().split()))
print(N - len(s))


import sys

def input():
	return sys.stdin.readline().rstrip()
(N, K) = list(map(int, input().split()))
d = []
A = []
for i in range(K):
	x = int(input())
	d.append(x)
	a = list(map(int, input().split()))
	A.append(a)
vec = [0] * N
for a in A:
	for i in a:
		i -= 1
		vec[i] += 1
ans = 0
for i in range(N):
	if vec[i] == 0:
		ans += 1
print(ans)


(n, k) = list(map(int, input().split()))
l1 = []
safe = []
ans = 0
for i in range(k):
	d = int(input())
	l = list(map(int, input().split()))
	safe += l
for i in range(1, n + 1):
	if i not in list(set(safe)):
		ans += 1
print(ans)


(N, K) = map(int, input().split())
l = []
for i in range(K):
	_ = input()
	l = set([*l, *list(map(int, input().split()))])
print(N - len(l))


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


(N, K) = map(int, input().split())
n = set(range(1, 1 + N))
for i in range(K):
	input()
	n -= set(map(int, input().split()))
print(len(n))


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


(n, k) = map(int, input().split())
d = []
a = []
for i in range(k):
	d.append(int(input()))
	a.append(list(map(int, input().split())))
a = sum(a, [])
count = 0
for i in range(n):
	if i + 1 in a:
		continue
	count += 1
print(count)


(N, K) = map(int, input().split())
s = set()
for _ in range(K):
	input()
	for i in map(int, input().split()):
		s.add(i)
print(N - len(s))


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


(N, K) = map(int, input().split())
have = []
for i in range(K):
	D = int(input())
	a = list(map(int, input().split()))
	have += a
print(N - len(set(have)))