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):
def tot(lookup, n):
    print(n - len(lookup.keys()))

if __name__ == "__main__":
    import sys
    from collections import defaultdict as DD
    lookup = DD(list)
    n, k = [int(_) for _ in input().split()]
    for i in range(k):
        di = int(input())
        ss = [int(_) for _ in input().split()]
        for s in ss:
            lookup[s].append(i)
    tot(lookup, n)

Solution (Python):
N = input().split()
n= int(N[0])
k = int(N[1])
o = [0 for _ in range(n)]
a = 0
for i in range(k):
    A= input()
    a = int(A)
    q = input().split()
    for j in range(a):
        o[int(q[j])-1] += 1

print(o.count(0))

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

num = []

for i in range(K):
    d = int(input())
    s = list(map(int,input().split()))
    for j in s:
        num.append(j)

print(N - len(set(num)))

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

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

s = set()

for i in range(k):
    d = int(input())
    set_k = set(map(int, input().split()))
    s = s | set_k

print(n - len(s))

Solution (Python):
N,K=map(int, input().split())
d = []
A =[]
s = list(range(1,N+1))

for i in range(K):
  di = int(input())
  d += [di]
  Ai = list(map(int, input().split()))
  A += [Ai]
  

  for j in Ai:
    if j in s:
      
      s.remove(j)
      

ans = len(s)
print(ans)

Solution (Python):
N, K = list(map(int, input().split()))
d = []
A = []
for i in range(K):
  d.append(int(input()))
  for a in list(map(int, input().split())):
    A.append(a)
A = sorted(A)
count = 1
for i in range(len(A)-1):
  if A[i] != A[i+1]:
    count += 1
print(N-count)

Solution (Python):
import numpy as np 
import math

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

counter = 0
for i in range(N):
    if i+1 in A:
        counter == 0
    else:
        counter += 1

print(counter)

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

Solution (Python):
import sys
from io import StringIO
import unittest

def resolve():
    n,k = map(int, input().split())

    ds = []
    aks = []
    for i in range(k):
        ds.append(int(input()))
        aks.append(list(map(int, input().split())))

    dict = {}
    for i in aks:
        for j in i:
            dict[j] = 0

    print(n - len(dict.items()))


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3 2
2
1 3
1
3"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3 3
1
3
1
3
1
3"""
        output = """2"""
        self.assertIO(input, output)

if __name__ == "__main__":
    
    resolve()

Solution (Python):
from collections import defaultdict 
import math
if __name__ == '__main__':
    s = input().rstrip().split(' ')
    N,K = int(s[0]), int(s[1]) 
    d = []
    candycount = defaultdict(int)
    for k in range(K):
        d.append(int(input()))
        s = input().rstrip().split(' ')
        for elem in s:
            candycount[int(elem)] += 1

    c = 0

    for k in range(1,N+1):
        if not k in candycount:
            c += 1

    print(c)

Solution (Python):
n,k=map(int,input().split())
d=[]
a=[]
b=0
for i in range(k):
    d.append(int(input()))
    a.append(list(map(int,input().split())))




import itertools



c=list(itertools.chain.from_iterable(a))
for i in range(1,n+1):
    if c.count(i)==0:
        b+=1
print(b)

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

print(x)

Solution (Python):
def main():
    n, k = [int(v) for v in input().strip().split(' ')]
    lst_is_possession = [False for _ in range(n)]

    for _ in range(k):
        _ = input()
        lst_possession_peple = [int(v) - 1 for v in input().strip().split(' ')]
        for p in lst_possession_peple:
            lst_is_possession[p] = True
    ans = n - sum(lst_is_possession)
    print(int(ans))


if __name__ == '__main__':
    main()

Solution (Python):
n, k = map(int, input().split())
sunuke = [False for i in range(n + 1)]
for i in range(k):
    input()
    for a in map(int, input().split()):
        sunuke[a] = True
print(len([s for s in sunuke[1:] if not s]))

Solution (Python):
a,b=map(int,input().split())
list1=[0]*(a+1)
for i in range(b):
    c=int(input())
    d=list(map(int,input().split()))
    for j in d:
        list1[j]+=1
for i in range(list1.count(0)):
    list1.remove(0)
print(a-len(list1))

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


def main():
    N, K = map(int, input().split())
    sunuke = [0]*N
    for _ in range(K):
        A = []
        d = int(input())
        A = map(int, input().split())
        for j in A:
            sunuke[j-1] += 1
    answer = collections.Counter(sunuke)
    print(answer[0])


if __name__ == '__main__':
    main()

Solution (Python):
N,K=map(int,input().split())
T=[x+1 for x in range(N)]
for y in range(K):
    a=int(input())
    b=list(map(int,input().split()))
    for z in range(a):
        if b[z] in T:
            T.remove(b[z])
print(len(T))

Solution (Python):
tmp = input().split()
N = int(tmp[0])
K = int(tmp[1])
sunuke = [0]*N

for k in range(K):
    tmp = input().split()
    d = int(tmp[0])
    tmp = input().split()
    for di in range(d):
        A = int(tmp[di])
        sunuke[A-1] = sunuke[A-1] + 1

trick = 0

for s in sunuke:
    if s == 0:
        trick = trick + 1

print(trick)

Solution (Python):
N,K=map(int, input().split())
ls=[]
for i in range(N):
    ls.extend([i])
for i in range(K):
    input()
    temp=list(map(int,input().split()))
    for j in temp:
        try:
            ls.remove((j-1))
        except:
            pass
print(len(ls))

Solution (Python):



n, k = map(int, input().split())
A = [1]*n
for i in range(k):
    d = int(input())
    x = [int(h) for h in input().split()]
    for k in x:
        if A[k - 1] == 1:
            A[k - 1] = 0

sum = 0
for m in A:
    sum += m
print(sum)

Solution (Python):
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()))

A=[]
for i in range(len(a)):
  for j in range(len(a[i])):
    A.append(a[i][j])

print(N-len(set(A)))

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

print(N-len(a))

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

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

    for j in range(d):
        buf = a[j]-1
        ha[buf] += 1

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

print(ans)

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

count = 0
for j in sunuke:
    if j == 0:
        count += 1

print(count)

Solution (Python):
N, K = map(int,input().split())
state = [1 for i in range(N)]
for i in range(K):
  d = int(input())
  
  x = list(map(int, input().split()))
  for k in x:
    state[k-1] = 0
print(sum(state))

Solution (Python):
N,K=[int(x) for x in input().split()]
c=[0]*N
for _ in range(K):
  d=int(input())
  A=[int(x) for x in input().split()]
  for i in A:
    c[i-1]=1
print(N-sum(c))

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

Solution (Python):

"""this is python work script"""
def main():
    """main function"""
    N, K = map(int, input().split(' '))
    answer_li = [1 for _ in range(N)]
    for _ in range(K):
        input()
        tmp_li = map(int, input().split(' '))

        for num in tmp_li:
            answer_li[num-1] = 0

    answer = sum(answer_li)
    print(answer)

if __name__ == '__main__':
    main()

Solution (Python):
NK = list(map(int, input().split()))
N = NK[0]; K = NK[1]

result = [0]*N

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

cnt = 0

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

print(cnt)

Solution (Python):
n,k=[int(_) for _ in input().split()]
list1=[]
for j in range(n):
    list1.append(j+1)
for i in range(k):
    q=int(input())
    b=[int(b) for b in input().split()][:q]
    for z in range(q):
        try:
            list1.remove(b[z])
        except:continue
            
print(len(list1))

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import Counter
def main():
    n, k = map(int, input().split())
    p = []
    for _ in range(k):
        d = int(input()) 
        a = [int(i) for i in input().split()]
        for i in a:
            p.append(i)   
    dd = Counter(p)    
    cnt = 0
    for i in range(1, n+1):
        if dd[i] == 0:
            cnt += 1
    print(cnt)
if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin
n,k = [int(x) for x in stdin.readline().rstrip().split()]
d = []
a = []
for i in range(k):
    d.append(int(input()))
    a.append([int(x) for x in stdin.readline().rstrip().split()])
b = [0]*n
for i in range(k):
    for j in range(d[i]):
        b[a[i][j]-1] = 1
ans =0
for i in range(n):
    if b[i] == 0:
        ans += 1
print(ans)

Solution (Python):
import numpy as np
n,k = map(int, input().split())
n_n = np.zeros(n+1) 
for i in range(k):
    d = input()
    a = map(int, input().split())
    for j in a:
        n_n[j] += 1
print(list(n_n).count(0)-1)

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

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

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

print(a.count(0))

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

Solution (Python):
import itertools

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

mans = []
for i in range(1, N+1):
    mans.append(i)

hasmans=[]
for ii in range(K):
    d = int(input())
    hasmans.append(list(map(int, input().split())))

hasmans = itertools.chain.from_iterable(hasmans)

print(len(list(set(mans) - set(hasmans))))

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

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

d = []
for i in range(k):
    d.append(int(input()))
    li = []
    li = input().split()
    a = a + li

print(n - len(set(a)))

Solution (Python):
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):
        if a[i] not in s:
            s.append(a[i])
print(n-len(s))

Solution (Python):
n, k = map(int, input().split())
s = list(map(int, range(1, n+1)))
for _ in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for a in a:
        if a in s:
            s.remove(a)

print(len(s))

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

sunukes = [0 for i in range(N)] 
for i in range(K):
    for j in range(d[i]):
        sunukes[A[i][j]-1] += 1

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

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

for i in range(K):
  b = input()
  c = list(map(int,input().split()))
  for j in range(len(c)):
    a[c[j]-1] += 1
count = 0
for i in range(N):
  if(a[i] == 0):
    count+=1

print(count)

Solution (Python):
n, k = list(map(int, input().split()))
d_list = []
for i in range(k):
  _ = input()
  d_list.append(list(map(int, input().split())))

sunukes = []
for i in range(n):
  sunukes.append(0)

for d in d_list:
  for a in d:
    sunukes[a-1] += 1

count = 0
for s in sunukes:
  count += 0 if s else 1
print(count)

Solution (Python):
n, k = map(int, input().split())
check = [0] * n
for i in range(k):
    D = int(input())
    A = list(map(int, input().split()))
    for d in range(D):
        if check[A[d] - 1] == 0:
             check[A[d] - 1] = 1
print(check.count(0))

Solution (Python):
n,k=map(int,input().split())
d=[]
al=[]
a=[0]*k
for i in range(k):
  d.append(int(input()))
  a[i]=input().split()
  for j in range(d[i]):
    al.append(a[i][j])
  
al=set(al)
print(str(n-len(al)))

Solution (Python):
n,k=map(int,input().split())
b=[0]*n
for i in range(k):
    m=int(input())
    a=list(map(int,input().split()))
    for j in range(len(a)):

            b[a[j]-1]+=1

print(b.count(0))

Solution (Python):
from collections import Counter

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

Solution (Python):
n, k = map(int, input().split())
lst = [0 for _ in range(n)]
dlst = []
for _ in range(k):
  d = int(input())
  dlst.append(list(map(int, input().split())))

dlst = sum(dlst, [])
dlst = set(dlst)
print(n - len(dlst))

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

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

for _ in range(K):
  d = int(input())
  L = input().split()
  L = [int(x) for x in L]
  for x in L:
    A[x-1] +=1
c = 0
for x in A:
  if x == 0:
    c +=1
print(c)

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

x = []
for i in range(N):
    x.append(1)

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

count = 0
for num in x:
    if num == 1:
        count += 1

print(count)

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

pe=[0]*N

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

Solution (Python):
def task(n, k, ak):
    table = {}

    for i in range(1, n + 1):
        table[i] = False

    for a in ak:
        for snack in a:
            table[snack] = True

    total = 0
    for flag in table.values():
        if not flag:
            total += 1

    print(total)


n, k = map(int, input().split())
ak = []
for i in range(0, k):
    d = int(input())
    a = list(map(int, input().split()))
    ak.append(a)

task(n, k, ak)

Solution (Python):
def flatten_by_extend(nested_list):
  flat_list = []
  for e in nested_list:
    flat_list.extend(e)
  return flat_list


n, k = input().split(' ')
n = int(n)
k = int(k)
a = []
for i in range(k):
  d = int(input())
  a.append(list(map(int, input().split())))

a = set(flatten_by_extend(a))
print(n - len(a))

Solution (Python):
n, k = map(int,input().split())
b = [False]*n
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in range(d):
        if b[a[j]-1]:
            continue
        b[a[j]-1] = True
print(b.count(False))

Solution (Python):
[N, K] = list(map(int, input().split()))
A_list = []
x = 0
for i in range(K):
  u = input()
  B_list = list(map(int, input().split()))
  A_list = A_list + B_list
for j in range(1,N+1):
  if not j in A_list:
    x = x + 1
print(x)

Solution (Python):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,k = mi()
a = [0] * n

for i in range(k):
    d = ii()
    at = li()
    for j in at:
        a[j-1] += 1

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

print(ans)

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

xs = [0] * n

for _ in range(0, k):
    input()
    tmp = map(int, input().split())
    for index in tmp:
        xs[index - 1] += 1

ans = 0
for a in xs:
    if a < 1:
        ans += 1

print(ans)

Solution (Python):
from sys import stdin
n, k = list(map(int, input().split()))

d_a = stdin.readlines()

a_s = [0] * n

for i in range(1, k * 2 + 1, 2):
    l_s = [int(x) for x in d_a[i].rstrip().split()]
    for n in range(len(l_s)):
        a_s[l_s[n]-1] = 1

res = 0
for su in range(len(a_s)):
    if a_s[su] == 0:
        res = res + 1

print(res)

Solution (Python):
n,k=map(int,input().split())
d=[]
a=[]

c=[]

for i in range(k):

    d.append(input())

    a=list(map(int,input().split()))

    for o in range(len(a)):

        c.append(a[o])

b=list(set(c))

print(n-len(b))

Solution (Python):
N,K =map(int,input().split())
have=[0]*N
for i in range(K):
    d=int(input())
    a_list=list(map(int,input().split()))
    for pick in a_list:
        have[pick-1]+=1


cnt=0
for chk in have:
    if(chk==0):
        cnt+=1
print(cnt)

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

sunukes = [0]*N

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

    for l in lis:
        sunukes[l-1] += 1

ans = 0
for s in sunukes:
    if s == 0:
        ans += 1

print(ans)

Solution (Python):
N, K = list(map(int, input().split()))
M = set()
S = set(range(1, N + 1))
for _ in range(K):
    d = int(input())
    M = M | set(map(int, input().split()))
ans = len(S - M)
print(ans)

Solution (Python):
import collections
n,k=input().split()
n=int(n)
k=int(k)
z=[]
for i in range(k):
    d=int(input())
    x=list(input().split())
    for i in range(d):
        z.append(x[i])
c = collections.Counter(z)
y=n-(len(c))
print(y)

Solution (Python):
from collections import Counter
import itertools


def main():
    N, K = (int(x) for x in input().split())
    A = []
    for i in range(K):
        d = int(input())
        A.append([int(x) for x in input().split()])
    A = itertools.chain.from_iterable(A)
    p = Counter(A)
    print(N-len(p))


if __name__ == "__main__":
    main()

Solution (Python):

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

Solution (Python):
N,K = map(int,input().split())
l = []
for i in range(K):
    d =int(input())
    r = input().split()
    for y in r:
        l.append(int(y))
    
ans = len(set(l))
print(N - ans)

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

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

print(n-sum(ans.values()))

Solution (Python):
if __name__ == '__main__':
    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
    print(snuke.count(0))

Solution (Python):
n, k = map(int, input().split())
t = []
for _ in range(k):
    d = int(input())
    for a in list(map(int, input().split())):
        t.append(a)

print(n-len(set(t)))

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

agent = [False] * (N+1)
agent[0] = True
for _ in range(K):
    _ = input()
    A = list(map(int, input().split()))
    for a in A:
        agent[a] = True



print(len(list(filter(lambda x: not x, agent))))

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

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

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

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

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

Solution (Python):






"""Module docstring
"""

import functools
import heapq
import itertools
import logging
import math
import random
import string
import sys
from argparse import ArgumentParser
from collections import defaultdict, deque
from copy import deepcopy
from typing import Dict, List, Optional, Set, Tuple


def solve(values: List[int], nb: int) -> int:
    for _v in values:
        pass
    return nb


def do_job():
    "Do the work"
    LOG.debug("Start working")
    
    N, K = map(int, input().split())
    snukes = [0] * N
    for _ in range(K):
        snack_nb = int(input())
        snuke_ids = list(map(int, input().split()))
        assert len(snuke_ids) == snack_nb
        for s in snuke_ids:
            snukes[s % N] += s
    
    
    
    result = snukes.count(0)
    LOG.debug((snukes))
    print(result)


def print_output(testcase: int, result) -> None:
    "Formats and print result"
    if result is None:
        result = "IMPOSSIBLE"
    print("Case 
    
    


def configure_log() -> None:
    "Configure the log output"
    log_formatter = logging.Formatter("%(lineno)d - " "%(message)s")
    handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(log_formatter)
    LOG.addHandler(handler)


LOG = None

if not LOG:
    LOG = logging.getLogger("template")
    configure_log()


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    parser = ArgumentParser()
    parser.add_argument(
        "-v",
        "--verbose",
        dest="verbose",
        action="store_true",
        default=False,
        help="run as verbose mode",
    )
    args = parser.parse_args(argv)
    if args.verbose:
        LOG.setLevel(logging.DEBUG)
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())


class memoized:
    """Decorator that caches a function's return value each time it is called.
    If called later with the same arguments, the cached value is returned, and
    not re-evaluated.
    """

    def __init__(self, func):
        self.func = func
        self.cache = {}

    def __call__(self, *args):
        try:
            return self.cache[args]
        except KeyError:
            value = self.func(*args)
            self.cache[args] = value
            return value
        except TypeError:
            
            
            return self.func(*args)

    def __repr__(self):
        """Return the function's docstring."""
        return self.func.__doc__

    def __get__(self, obj, objtype):
        """Support instance methods."""
        return functools.partial(self.__call__, obj)

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

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

sunuke = [0]*(n+1)

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

cnt = 0

for k in range(1, n+1):
    if sunuke[k] == 0:
        cnt += 1

print(cnt)

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

v = []
for _ in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    v.extend(a)

print(n - len(set(v)))

Solution (Python):
n,k = list(map(int,input().split()))
d = []
res = []
c = 0

for i in range(k):
    a = []
    d = int(input())
    a = list(map(int,input().split()))
    
    for j in a:
        if (j in res) == False:
            res.append(j)

for i in range(n):
    if ((i+1) in res) == False:
        c += 1

print(c)

Solution (Python):
N, K = map(int, input().split())
Ad_list = [list(map(int, input().split(' '))) for _ in range(K*2)]

result = {i: 0 for i in range(1, N+1)}
for i in range(1, K+1):
    index = i*2 - 1
    for k in Ad_list[index]:
        result[k] += 1

print(len({k for k, v in result.items() if v == 0}))

Solution (Python):
N,K = map(int,input().split())
line = list()
for i in range(K):
    n = int(input())
    line2 = list(map(int,input().split()))
    for j in range(n):
        line.append(line2[j])
print(N-len(set(line)))

Solution (Python):
N, K = map(int, input().split())
A = [[]]*K
d = [0]*K

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

ans = [0]*N
for i in range(K):
    for j in A[i]:
        ans[j-1] += 1

print(ans.count(0))

Solution (Python):
n, k = input().split()
sunuke = [0]*int(n)
for i in range(int(k)):
    d = input()
    dl = input().split()
    for j in dl:
        sunuke[int(j)-1] = 1
print(sunuke.count(0))

Solution (Python):
N,K = map(int,input().split())
sunuke_list=[str(i) for i in range(1,N+1)]
for i in range(K):
  d=int(input())
  kasi_list = list(map(str,input().split()))
  for j in kasi_list:
    try:
	    sunuke_list.remove(j)
    except:
      pass
    

print(len(sunuke_list))

Solution (Python):


def main():
    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 = [1 for _ in range(n)]
    for i in range(k):
        for b in a[i]:
            cnt[b-1] = 0

    print(sum(cnt))

if __name__ == '__main__':
    main()

Solution (Python):












arg = list(map(int, input().split())) 

N = arg[0]
K = arg[1]
S = range(1,N+1)
l = []

for i in range(K):
  D = int(input()) 
  A = list(map(int, input().split())) 
  for j in A:
    l.append(j)


AM = list(set(S) - set(l))

print(len(AM))

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

L = []
s = set()
for i in range(m):
    li = []
    d = int(input())
    e = list(map(int,input().split()))
    li.append(e)
        
    L.append(*li)

for i in range(m):
    for j in range(len(L[i])):
        s.add(L[i][j])

print(n-len(s))

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

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

result = 0 
A_all = list(itertools.chain.from_iterable(A_all))
for i in range(1, N + 1):
  if A_all.count(i) == 0:
    result += 1
      
print(result)

Solution (Python):
n, k = map(int, input().split())
a=[]
for i in range(k):
    d = int(input())
    a.append(list(map(int, input().split())))

ml=[]
for ai in a:
    ml.extend(ai)

ml = set(ml)

print(n-len(ml))

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

Solution (Python):
n,k = map(int,input().split())
a = []
for i in range(k):
    d = int(input())
    f = input().split()
    
    a.append(f)
b = []
for i in range(len(a)):
    for j in range(len(a[i])):
        b.append(int(a[i][j]))
c =set(b)

d = {i for i in range(1,n+1)}

print(len(d-c))

Solution (Python):
import math

def main():
    n, k = map(int, input().split())
    sunuke = [False] * n
    for i in range(k):
        d = int(input())
        A = map(int, input().split())
        for a in A:
            sunuke[a-1] = True

    print(sunuke.count(False))

main()

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
c = 0

for L in l:
    if(L == 0):c += 1
print(c)

Solution (Python):
N,K = map(int,input().split())
OkashiList = []
KesuList = []
for _ in range(K):
        d = int(input())
        li = list(map(int,input().split()))
        OkashiList.append(li)
for i in OkashiList:
    for j in i:
        if j in KesuList:
            pass
        else:
            KesuList.append(j)
ans = N - len(KesuList)
print(ans)

Solution (Python):
import sys

lines = sys.stdin.readlines()

X = lines[0].split(' ')
N = int(X[0])
K = int(X[1])

S =[]
for i in range(N):
    S.append(0)


for j in range(K):
    d = int(lines[2*j +1])
    A = lines[2*j +2].split(' ')
    for k in range(d):
        S[int(A[k])-1] +=1

P = 0
for i in range(N):
    if S[i] == 0:
        P += 1

print(P)

Solution (Python):
N,K = map(int,input().split())
l = [0]*N
sum = 0

for i in range(K):
    d = int(input())
    l2 = list(map(int,input().split()))
    for j in range(d):
        l[l2[j]-1] += 1

for i in range(N):
    if l[i]==0:
        sum += 1

print(sum)

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

check_list = list(range(1,N+1))

for i in range(K):
  d = int(input())
  a = list(map(int, input().split()))
  for j in a:
    if j in check_list:
      check_list.remove(j)
print(len(check_list))

Solution (Python):

n, k = map(int, input().split())
dn = []
dls = []

for i in range(k):
    dn.append(int(input()))
    dls.append(list(map(int, input().split())))

print(n-len(set(sum(dls,[]))))

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


is_sunuke_have_sweets_list = [False for _ in range(n)]
for i in range(k):
    d = int(input())
    a_list = list(map(int, input().split()))

    for a in a_list:
        is_sunuke_have_sweets_list[a-1] = True

    
    

print(is_sunuke_have_sweets_list.count(False))