peterverebics/CodeNet_Python_118 huggingface dataset:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

A, B, C, K = map(int, input().split())

ans = 0
if K <= A:
    print(K)
    quit()
K -= A
ans = A
if K <= B:
    print(ans)
    quit()
K -= B
ans -= C - K - 1
print(ans)
A,B,C,K=map(int,input().split())

if A+B>=K:
    print(A)
else:
    m=K-(A+B)
    print(A-m)
a,b,c,k=map(int,input().split())
if a+b >= k:
    vis= a
else:
    vis= a + (-1*(k-a-b))
    
print(vis)
A, B, C, K = map(int, input().split())

s = 0

if K <= A+B:
    print(A)
else:
    print(A+B-C)
a,b,c,k = map(int, input().split())

if a < k:
  print(a - (k - a - b))
else:
  print(a)
A, B, C, K = map(int,input().split())
# 1 0 -1 Num
result = 0
if K <= A + B:
	print(A)
else:
	x = K-A-B
	if C < x:
		print(0)
	else:
		print(A-x)
a,b,c,k = [int(x) for x in input().split(' ')]


def verify_sum(a,b,c,k):
    if k == a:
        print(a)
        return

    num_cards = a + b

    if k > num_cards:
        print(a - (k - num_cards))
    else:
        print(a)

verify_sum(a,b,c,k)
a,b,c,k = map(int, input().split())
if a >= k:
  print(k)
else:
  k -= a + b
if k <= 0:
  print(a)
else:
  print(a-k)
a, b, c, k = map(int, input().split())
# print(a)
# print(b)
# print(c)
# print(k)

# sum = (1) * (a) + (0) * (k-a) + (-1) * (k-a-b)

sum = (1) * (a) + (-1) * (k-a-b)

# if k-a <= b:
#   sum = sum + (0) * (k-a)
# else:
#   sum = sum + (0) * b

# sum = sum + (-1) * (k-a-b)

# print('sum')
print(sum)
A,B,C,K = map(int, input().split())
total = 0
if A <= K:
    total = A
    if B <= K - A:
        total = total - (K-A)
print(total)
a, b, c, k = map(int, input().split())
print(a - max(k - a - b, 0))
a, b, c, k = list(map(int, input().split()))

s = 0
if k <= (a + b):
	s = a * 1
else:
	s = (a * 1) + (k-(a+b)) * (-1)
print(s)
a, b, c, k = map(int, input().split())

if k <= a + b:
    print(k)
    exit(0)

print(a - (k - (a + b)))
A,B,C,K=list(map(int,input().split()))
if A>=K:
    print(A)
elif A<K and (A+B)>=K:
    print(A)
elif A<K and (A+B)<K:
    m=A-C
    if m<=0:
        print("0")
    else:
        print(m)
A, B, C, K = map(int, input().split())

if A > K:
    print(K)
else:
    ans = A
    K -= A
    K -= B
    if K:
        ans -= K

    print(ans)
a,b,c,k = map(int,input().split())
x = 0
if k == a:
    print(a)
elif k <= a + b:
    x = a
    k = k - a
    if b > k:
        print(a)
    else:
        k = k - b
        print(a)
elif k <= a + b + c:
    x = a
    k = k - a - b
    x = x - k * 1
    print(x)
a, b, c, k = map(int, input().split())

if k <= a:
    print(a)
elif a < k <= a + b:
    print(a)
else:
    print(a - (k - a - b))
#S = str(input())
A, B, C, K = map(int,input().split())

a = A

if B <= K-a:
    b = B
else:
    b = K-a

if C <= K-a-b:
    c = C
else:
    c = K-a-b
ans = a - c
print(ans)
import sys

a, b, c, k = map(int, input().split())

nokori = k - a

if nokori <= 0:
    print(k + nokori)
    sys.exit()

nokori = nokori - b

if nokori <= 0:
    print(a)
    sys.exit()

print(a - nokori)
a , b ,c , k = input().split()
a,b,c,k = int(a) , int(b) , int(c) , int(k)
count=a
k -= a
while b>0 and k>0:
    k-=1
    b-=1
while c>0 and k>0:
    count+=-1
    k-=1
    c-=1
print(count)
A,B,C,K = map(int,input().split())

ans = 0
if K >= A:
    ans += (A)*1
    K -= A
    judge = 1
else:
    ans += A*1
    judge = 0



if judge==1 and K-B>0:
    K -= B
    judge = 1
elif judge==1 and K-B<=0:
    K-=B
    judge = 0


if judge==1:
    ans += K*-1

print(ans)
one,zero,minus,k = map(int,input().split())
result = 0
if one >= k:
    print(k)
else:
    if k >= one and one > 0:
        result += one
        k -= one
    if zero >= k:
        print(result)
    else:
        if k >= zero and zero > 0:
            k -= zero
            if minus > 0:
                print(result-k)
a,b,c,d = (int(x) for x in input().split())

ans = 1 * a
count = d - a

if count - b > 0:
  ans = ans + 0 * b
  count = count - b
  
if count - c > 0:
  ans = ans -1 * c
  
print(ans)
A,B,C,K = map(int,input().split())
ans = 0

if A <= K:
    ans += A
    if B <= K-A:
        ans += 0
        if C <= K-A-B:
            ans -= K-A-B
    else:
        ans += 0
else:
    ans += K
print(ans)
A, B, C, K = list(map(int, input().split()))

if K <= A:
    ans = K
elif K <= A + B:
    ans = A
else:
    ans = A - K + C

print(ans)
import bisect,collections,copy,heapq,itertools,math,string
from collections import defaultdict as D
from functools import reduce
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")

a,b,c,k=LI()

if k<=a+b:
    ans = a
else:
    ans = a - (k - (a + b))
print(ans)
a, b, c, k = map(int, input().split())

if k == 1:
    print(k)
elif k <= a + b:
    print(k)
else:
    r = k - a - b
    print(a-r)
a,b,c,k = map(int,input().split())
if 1 <= k <= a+b:
  print(a)
else:
  print(2*a+b-k)
A, B, C, K = list(map(int, input().split()))

if( A + B >= K ):
    if(A >= K):
        print(A)
    else:
        print(K)
else:
    print(+1*A -1*(K-(A+B)))
a, b, c, k = map(int, input().split())
if a >= k:
    print(1*a)
elif a < k and b >= k-a:
    print (1*a)
else:
    print(1*a + 0*b + (k-a-b)*(-1))
a, b, c, k = map(int, input().split())

if (a >= k):
    print(k)
elif ((a + b) >= k):
    print(a)
else:
    max_num = a + b - k
    print(max_num)
a, b, c, k = map(int, input().split())
if k <= a:
    k_pa, k_pb, k_pc = k , 0, 0 
elif k >= a and k-a <= b:
    k_pa, k_pb, k_pc = a, k-a, 0
elif k >= a and k-a >= b:
    k_pa, k_pb, k_pc = a, k-a, k-a-b
point = k_pa - (k-k_pa-k_pb)
print(point)
abck = input('')
a = int(abck.split(' ')[0])
b = int(abck.split(' ')[1])
c = int(abck.split(' ')[2])
k = int(abck.split(' ')[3])

cnt=0
left=k

#A
if a > k:
    left=0
    cnt=a
else:
    left-=a
    cnt+=a

if left>0:
    left-=b

if left>0:
    if left > c:
        cnt-=c
    else:
        cnt-=left
    
print(cnt)
A, B, C, K = map(int, input().split())
if (K <= A):
  print(1 * K)
K1 = K - (A + B)
if (K1 <= 0):
  print(1 * A)
else:
  print(1 * A + (-1 * K1))
A, B, C, K = map(int, input().split())
if A >= K:
    print(1 * K)
if K <= A+B:
    print(1 * A + 0 * (K - A))
else:
    print(1 * A + 0 * B + (-1) * (K - A - B))
# -*- coding: utf-8 -*-
A, B, C, K = map(int, input().split())

ans = 0
end_flag = False

if K > A:
    ans += A

else:
    ans = K
    end_flag = True

if end_flag == False and K - A > B:
    ans += 0

else:
    ans += 0
    end_flag = True

if end_flag == False and K - A - B > C:
    ans += -C

else:
    ans += -(K - A - B)

print(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())))
    
aa=[0]*N
counts=0

for k in a:
    for j in k:
        aa[j-1]+=1
        
for x in aa:
    if x==0:
        counts+=1

print(counts)
n,k = [int(ch) for ch in input().split()]
snuckList = []
for i in range(n):
    snuckList.append(i+1)
for i in range(k):
    cnt = int(input())
    snucks = [int(ch) for ch in input().split()]
    for snuck in snucks:
        if snuck in snuckList: 
            snuckList.remove(snuck)
print(len(snuckList))
N, K = map(int, input().split())
A = []
for i in range(K):
    di = int(input())
    Ai = list(map(int, input().split()))
    A.extend(Ai)

print(N - len(set(A)))
def main():
    N, K = map(int, input().split())

    ds = []
    current_members = set(range(1,N+1))
    for i in range(K):
        d = int(input())
        members= map(int, input().split())
        current_members -= set(members)
    
    #print(current_members)
    print(len(current_members))


if __name__ == '__main__':
    main()
N, K = map(int, input().split(" "))
# print(N, K)

people = []

for i in range(0, K):
  d = int(input())
  A = list(map(int, input().split(" ")))
  # print(d, A)
  for j in range(d):
    people.append(A[j])

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

print(n - len(x))
(n, k) = list(map(int, input().split()))
snk = set(range(1, n + 1))
items = []
for i in range(k):
    d = int(input())
    for a in list(map(int, input().split())):
        if a in snk:
            snk.remove(a)
print(len(list(snk)))
from math import sqrt,ceil,floor
def mi():return map(int,input().split())
def li():return list(mi())
def ii():return int(input())

n,k=mi()
m=[0]*(n+1)
for i in range(k):
    d=ii()
    a=li()
    for i in a:
        m[i]+=1
        
m=m[1:]
print(m.count(0))
ninzu, syurui = map(int, input().split())

shoji = [ 0 for _ in range(ninzu) ]

for _ in range(syurui):
    num = int(input())
    
    if num == 1:
        man = int(input())
        shoji[man-1] += 1
    else:
        mans = map(int, input().split())
        for man in mans:
            shoji[man-1] += 1

ans = 0
for sman in shoji:
    if sman == 0:
        ans += 1

print(ans)
N, K = [int(x) for x in input().split()]
snuke_list = []
for i in range(K):
    d = int(input())
    snuke_list.extend([int(x) for x in input().split()])

print(N - len(set(snuke_list)))
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()
N, K = map(int, input().split())
sunukes = {i for i in range(1,N+1)}

for _ in range(K):
    d = int(input())
    sunukes_having = set(map(int, input().split()))
    sunukes -= sunukes_having

print(len(sunukes))
N, K = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(K*2)]

indexs = []
for i in range(len(L)):
    if i%2 != 0:
        indexs.append(L[i])

uniq_list = []
for li in indexs:
    for e in li:
        if e not in uniq_list:
            uniq_list.append(e)

print(N - len(uniq_list))
N, K = map(int, input().split())
sunuke = set([x for x in range(1,N+1)])
for k in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    sunuke.difference_update(A)
    
print(len(sunuke))
inputlist = list(map(int, input().split()))
snum = inputlist[0]
kindofsweets = inputlist[1]
setofkind = []
for i in range(kindofsweets):
    input()
    setofkind += (list(map(int, input().split())))
counter = 0
for i in range(snum):
    if i + 1 not in setofkind:
        counter += 1
print(counter)
n,k=map(int,input().split())
a=[1]*n
for i in range(k):
    d=int(input())
    x=list(map(int,input().split()))
    for j in x:
        a[j-1]=0
print(sum(a))
import itertools
N,K = map(int,input().split())
d = list()
A = list()
for _ in range(K):
    d.append(int(input()))
    A.append(list(map(int,input().split())))
A = list(itertools.chain.from_iterable(A))
A = set(A)
print(N-len(A))
x=input()
x_list=x.split()
N=int(x_list[0])
K=int(x_list[1])

Z=set()

for i in range(K):
  s=int(input())
  c=input()
  c_list=c.split()
  for r in c_list:
    Z.add(r)
  
print(N-len(Z))
from sys import stdin, setrecursionlimit

setrecursionlimit(10 ** 9)


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

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

s = set()
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    s |= set(A)

ans = set(range(1, N+1)) - s
print(len(ans))
inputs = []
while True:
  try:
    inputs.append(input())
  except EOFError:
    break

# print(inputs)

people = eval(inputs[0].split(" ")[0])
snack = eval(inputs[0].split(" ")[1])

having_snacks = [[eval(i) for i in a.split(" ")] for a in inputs[2::2]]
having_snacks = set(sum(having_snacks, []))

print(people - len(having_snacks))
N,K = map(int,input().split())
treats = [[False for i in range(110)] for j in range(110)]

res = 0

for i in range(1,K+1,1):
  d = int(input())
  A = [i for i in map(int,input().split())]
  for a in A:
    treats[i][a] = True
    
for j in range(1,N+1,1):
  flag = 1
  for i in range(1,K+1,1):
    if treats[i][j] == True:
      flag = 0
      
  if flag: res += 1
    
print(res)
N,K=(int(x) for x in input().split())
lists=[0]*N
while 1:
    try:
        tmp=int(input())
    except :
        break
    have_count=(int(x) for x in input().split())
    for i in have_count:
        lists[i-1]=1
print(lists.count(0))
N, K = map(int, input().split())
X = [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):
    X[A[j]-1] += 1

print(X.count(0))
data = input().rstrip().split(" ")
people = int(data[0])
kind = int(data[1])
ans = [i+1 for i in range(people)]
for j in range(kind):
    empty = input()
    have = input().rstrip().split(" ")
    for k in have:
        if int(k) in ans:
            delete = ans.index(int(k))
            del ans[delete]
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)
import sys
N, K = map(int, sys.stdin.readline().rstrip().split())
number = list(range(1, N+1))
lists = []
for i in range(K):
  d = sys.stdin.readline().rstrip()
  li = [int(x) for x in sys.stdin.readline().rstrip().split()]
  for k in li:
    if k in number:
      number.remove(k)
  lists.append(li)
#print(lists)
print(len(number))
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

# print(a)

c = 0
for i in range(1, N+1, 1):
    if x[i] == 0:
        c += 1

print(c)
from collections import Counter

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

l = []
counter = 0

for k in range(K):
    d = int(input())
    A = map(int, input().split())
    l.extend(A)

for i in range(1,N+1):
    if Counter(l)[i]==0:
        counter += 1
    else:
        continue

print(counter)
n, k = map(int, input().split())
ans = [0]*n
for i in range(k):
    d = int(input())
    a_list = list(map(int, input().split()))
    for j in range(len(a_list)):
        ans[a_list[j]-1] += 1
print(ans.count(0))
N,K=map(int,input().split())
arr=[0]*N
for _ in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    for a in A:
        arr[a-1]=1
print(N-sum(arr))
# ABC166 B

def main():
    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 A:
            sunuke[j-1] += 1
    
    print(sunuke.count(0))



if __name__ == '__main__':
    main()
N,K = map(int,input().split())
li = []
count = 0
for i in range(K):
    d = int(input())
    a = list(map(int,input().split()))
    for j in range(d):
        li.append(a[j])

for i in range(N):
    if i+1 not in li:
        count += 1

print(count)
n,k=map(int,input().split())
s=set()
for i in range(k):
  _=input()
  s|=set(input().split())
print(n-len(s))
# import numpy as np
# from itertools import permutations
# from itertools import combinations
# from itertools import combinations_with_replacement
# import queue
# import heapq


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

    sunuke = [True for _ in range(N)]

    for i in range(K):
        d = input()
        ds = list(map(int, input().split()))

        for s in ds:
            sunuke[s-1] = False

    print(sum(sunuke))


if __name__ == "__main__":
    main()
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())
person = []
for i in range(k):
    num_d = int(input())
    d_list = input().split()
    person.extend(d_list)
person = list(set(person))
print(n-len(person))
N,K=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(2*K)]
B=[]
for i in range(K):
    B=B+A[i*2+1]
print(N-len(set(B)))
N, K = map(int, input().split())

answer = [1] * N

for i in range(K):
	d = int(input())
	tmp = map(int, input().split())

	for j in tmp:
		answer[j-1] = 0

print(sum(answer))
n,k = map(int,input().split())
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    if i == 0:
        ans = [i for i in range(1,n+1)]
    for i in a:
        if i in ans:
            ans.remove(i)
print(len(ans))
N, K = map(int, input().split())
D = []
A = [[] for i in range(200)]
for i in range(K):
    d = int(input())
    D.append(d)
    a = list(map(int, input().split()))
    A[i] = a

ans = 0
for i in range(1, N+1):
    num = 0
    for j in range(K):
        for k in range(D[j]):
            if A[j][k] == i:
                num = 1
    if num == 0:
        ans += 1
print(ans)
n, k = map(int, input().split())
l = [1] * n
for _ in range(k):
    d = int(input())
    for i in map(int, input().split()):
        l[i - 1] = 0
print(sum(l))
n, k = map(int, input().split())
ans = [0] * n
cnt = 0
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in a:
        ans[j-1] += 1
for i in ans:
    if i == 0:
        cnt += 1
print(cnt)
n,k = list(map(int,input().split()))

snk_list = []
for i in range(k):
    input()
    b = list(map(int,input().split()))
    snk_list+=b

print(n-len(set(snk_list)))
N, K = map(int, input().split())

L = [0 for i in range(N+1)]

for i in range(K):
  d = int(input())
  LL = list(map(int, input().split()))
  for j in range( len(LL) ):
    L[ LL[j] ] += 1

ans = 0
for i in range(1,N+1):
  if L[i] == 0:
    ans += 1
print(ans)
(n, k) = map(int, raw_input().split())

snakes = [[] for i in xrange(n + 1)]

for i in xrange(k):
    s = int(raw_input())
    ns = map(int, raw_input().split())

    for num in ns:
        snakes[num].append(s)

tot = 0
for i in xrange(1, n + 1):
    if not snakes[i]:
        tot += 1
print tot
n, k = map(int, input().split())
ls = []
for i in range(n):
    ls.append(1)
for i in range(k):
    input()
    ts = map(int, input().split(' '))
    for t in ts:
        ls[t-1] = 0
print(sum(ls))
N, K = map(int, input().split())
d = []
A = []

for _ in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))

cnt = {}
for i in range(N):
    cnt.setdefault(str(i + 1), 0)

for Ai in A:
    for Aij in Ai:
        cnt[str(Aij)] += 1

ans = 0
for key, val in cnt.items():
    if val == 0: ans += 1

print(ans)
N, K = list(map(int, input().split()))
a = []
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    a.extend(A)
print(N - len(set(a)))
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))
# ABC166
# B Trick or Treat
N, K = map(int, input().split())
A = [list(map(int, input().split())) for i in range(K*2)]
D = list(A[::2])
del A[::2]
A = sum(A, [])
a = set(A)
OP = [n +1 for n in range(N)]
op = set(OP)
an = op - a
print(len(list(an)))
from sys import stdin
import sys

# A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]
N, K = [int(x) for x in stdin.readline().rstrip().split()]
ans = [0 for i in range(N)]
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for i in range(len(A)):
        ans[A[i]-1] += 1
cnt=0
for i in range(len(ans)):
    if ans[i] == 0:
        cnt += 1
print(cnt)
N, K = map(int, input().split())
d = []
A = []
for i in range(K):
    d.append(int(input()))
    A.append(input().split())
    
child = list(range(1, N+1))
non_child = list(range(1, N+1))

for i in child:
    for j in range(K):
        for k in range(d[j]):
            if i == int(A[j][k]):
                non_child.remove(i)
                break
        else:
            continue
        break

print(len(non_child))
N, K = map(int, input().split())
st = set()
for _ in range(K):
    input()
    st |= set(map(int, input().split()))
print(len(set(range(1, N + 1)) - st))
N,K = map(int,input().split())
P = [0 for i in range(N)]
for i in range(K):
    a = int(input())
    b = list(map(int,input().split()))
    for j in range(a):
        P[b[j]-1] = 1
m = 0   
for i in range(N):
    if P[i] == 0:
        m += 1
print(m)
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()
n, k = map(int, input().split())
ans = []
for i in range(k):
    x = int(input())
    x = list(map(int, input().split()))
    for j in x:
        ans.append(j)
ans = set(ans)
cnt = 0
for i in range(1, n+1):
    if not i in ans:
        cnt += 1
print(cnt)
N, K = map(int, input().split())
t = [1] * N
for i in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for a in A:
    t[a-1] = 0
print(sum(t))
def resolve():
    N, K = map(int, input().split())
    C = [0] * N
    for i in range(K):
        input()
        A = list(map(int, input().split()))
        for a in A:
            C[a-1] += 1

    print(C.count(0))

if __name__ == '__main__':
    resolve()
n, k = [int(i) for i in input().split()]
s = [i + 1 for i in range(n)]
for i in range(k):
  d = int(input())
  ns = [int(j) for j in input().split()]
  for l in ns:
    s.remove(l) if l in s else None
print(len(s))
from sys import stdin
import re
import bisect
import numpy as np

N, K = map(int, stdin.readline().rstrip().split())
frag = np.zeros((K,N), dtype=bool)
for i in range(K):
    _ = stdin.readline()
    line = map(int, stdin.readline().rstrip().split())
    for j in line:
        j -= 1
        frag[i][j] = True
        
count = int(0)
frag = frag.T
for i in range(N):
    if np.count_nonzero(frag[i] == 1) == 0:
        count += 1
print(count)
n, k = map(int, input().split())
snuke = [1 for i in range(n)]
for _ in range(k):
	d = int(input())
	a = list(map(int, input().split()))
	for i in a:
		snuke[i -1] = 0
		
print(sum(snuke))
n,k = list(map(int,input().split()))

ni = [0]*n

while k > 0:
    d = int(input())
    a = list(map(int,input().split()))
    k -= 1
    for i in a:
        ni[i-1] = 1

print(ni.count(0))
n,k = [int(x) for x in input().split()]
a = []
for _ in range(k):
    _ = input()
    tmp = [int(x) for x in input().split()]
    for x in tmp:
        a.append(x)

print(n - len(set(a)))
[N, K] = list(map(int, input().split()))
dList = []
AList = []
snuckSnack = {}
for i in range(K):
    dList.append(int(input()))
    AList.append(list(map(int, input().split())))
for i in range(1,N+1):
    snuckSnack[i] = set()
for i in range(K):
    for j in AList[i]:
        snuckSnack[j].add(dList[i])
vicCount = 0
for i in range(1,N+1):
    if snuckSnack[i] == set():
        vicCount += 1
print(vicCount)
N, K = [int(_) for _ in input().split()]

records = []
for i in range(K):
    d = input()
    records.extend([int(_) for _ in input().split()])

records = list(set(records))
print(N-len(records))
n, k = map(int, input().split())
sunuke = list()
cnt = 0
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    sunuke.extend(a)
for j in range(1, n + 1):
    if j not in sunuke:
        cnt += 1
print(cnt)
def main() -> None:
    n, k = 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


if __name__ == '__main__':
    main()
import numpy as np

n,k = map(int, input().split())

p = np.zeros(n)


for i in range(k):
  input()
  l = np.array(list(map(int, input().split())))
  p[l-1] += 1

print(len(np.where(p==0)[0]))
n, k = map(int, input().split())

okashi = {}
for i in range(k):
    d = int(input())
    a_list = input().split()
    for a in a_list:
        if not a in okashi:
            okashi[a] = True

print(n - len(okashi))