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



Sample input:
3 2
2
1 3
1
3


Sample output:
1

Submission status: Accepted

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

Submission status: Accepted

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

    snuke = [1] * N
    for _ in range(K):
        _ = int(input())
        A = (int(x) - 1 for x in input().split())
        for x in A:
            snuke[x] = 0
    print(sum(snuke))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

snacker = set()

for i in range(K):
    dummy=input()
    for j in [int(k) for k in input().split()]:
        snacker.add(j)
print(N-len(snacker))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
sunuke = []
for s in range(n):
    sunuke.append(str(s+1))

for t in range(k):
    d = int(input())
    hito = input().split(" ")
    for u in range(d):
        for v in range(n):
            if hito[u] == sunuke[v]:
                sunuke[v] = 0
            else:
                pass

m = sunuke.count(0)
print(n-m)

Submission status: Accepted

Solution code:
n,k = list(map(int,input().split()))
sunuke = [i for i in range(1,n+1)]
have = []
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for i in a:
        have.append(i)

ans = list(set(sunuke) - set(have))
print(len(ans))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
sunuke_and_sweets_cnt = [0] * N # index is sunuke, value is sweets count
for i in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for j in range(d):
    sunuke_and_sweets_cnt[A[j] - 1] += 1
ans = 0
for sweets in sunuke_and_sweets_cnt:
  if sweets == 0:
     ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

A = [0] * N
#print(A)
#print(type(A))

for okashi_number in range(k):
	di = int(input())
	D = list(map(int,input().split()))
	for x in range(di):
		A[D[x]-1]= 1
#print(A)
count = 0
for i in range(N):
	if A[i] == 0:
		count = count + 1
print(count)

Submission status: Accepted

Solution code:
import collections
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()))
B = []
for l in range(K):
    B += A[l]
c = collections.Counter(B)
values, counts = zip(*c.most_common())
ans = N - len(values)
print(ans)

Submission status: Accepted

Solution code:
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 = itertools.chain.from_iterable(a)
b = set(a)

print(N - len(b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
line = [0 for i in range(n)]
count = 0
for i in range(k):
  d_i = int(input())
  A_list = list(map(int, input().split()))
  for j in A_list:
    line[j-1] += 1
for i in line:
  if i == 0:
    count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
nums = [i for i in range(N)]
for i in range(K):
    d = int(input())
    s = list(map(int, input().split()))
    for j in s:
        if j-1 in nums:
            nums.remove(j-1)

print(len(nums))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
check = [False] * n
d = []
a = []
for i in range(k):
  d = int(input())
  a.append(list(map(int, input().split())))
for i in range(k):
  for j in range(len(a[i])):
    check[a[i][j]-1] = True
print(check.count(False))

Submission status: Accepted

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

okashi = set()
for _ in range(k):
  d = int(input())
  lst = [int(i) for i in input().split()]
  for i in range(d):
    if lst[i] not in okashi:
      okashi.add(lst[i])
count = 0
for i in range(n):
  if i + 1 not in okashi:
    count += 1
print(count)

Submission status: Accepted

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

n_l = [1]*n

for i in range(k):
    a = int(input())
    for k in list(map(int, input().split())):
        n_l[k-1] = 0

print(sum(n_l))

Submission status: Accepted

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

okashi_holders = set()

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

print(N - len(okashi_holders))

Submission status: Accepted

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

okashi_holders = set()

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

print(len(set(range(1, N + 1)) - okashi_holders))

Submission status: Accepted

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

Submission status: Accepted

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

myset = set()
for i in range(k):
    d=input()
    l=list(map(int,input().split()))
    myset |= set(l)

print(n-len(myset))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ans = []
count = 0

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ans = []
count = 0

for i in range(k):
  d = int(input())
  l = list(map(int, input().split()))
  for j in range(d):
    if l[j] not in ans:
      ans.append(l[j])

for i in range(n):
  if i+1 not in ans:
    count += 1
  
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def resolve():
    N, K = map(int, input().split())
    D = []
    A = []
    for _ in range(K):
        d = int(input())
        a = list(map(int, input().split()))
        D.append(d)
        A.append(a)
    ans = 0
    for i in range(N):
        flag = 0
        for j in range(K):
            if i+1 in A[j]:
                flag = 1
        if flag == 0:
            ans += 1
    print(ans)
resolve()

Submission status: Accepted

Solution code:
n, k = map(int,input().split())
num = []
for i in range(k):
    j = int(input())
    list_1 = list(map(int,input().split()))
    for l in range(j):
        num.append(list_1[l])
        
ans = set(num)
print(n - len(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.readline
import time
import math
import itertools as it
def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
start_time = time.perf_counter()
# ------------------------------

N, K = inpl()
dp = [False] * N
for i in range(K):
    d = inp()
    A = inpl()
    for a in A:
        dp[a-1] = True
cnt = 0
for bl in dp:
    if not bl:
        cnt += 1
print(cnt)

# -----------------------------
end_time = time.perf_counter()
print('time:', end_time-start_time, file=sys.stderr)

Submission status: Accepted

Solution code:
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 range(d):
        l[a[j] - 1] += 1
        
count = 0        
for i in range(n):
    if l[i] == 0:
        count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = set()
for i in range(k):
    d = int(input())
    a |= set(map(int, input().split()))
print(len(set(range(1, n + 1)) - a))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
DA = [(int(input()), list(map(int, input().split()))) for _ in range(K)]

l = [0]*N
for d, a in DA:
    for ai in a:
        ai = ai-1
        l[ai] += 1

print(l.count(0))

Submission status: Accepted

Solution code:
N,K  = map(int,input().split())
S = set()
for i in range(K) :
    D=int(input())
    L=list(map(int, input().split()))
    for A in L :
         S.add(A)
print (N-len(S))

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#l = list(map(int, input().split()))

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

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


ans = 0
for i in temp:
    if (i == 0):
        ans += 1

print (ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
a = []
n = 1

while n <= N:
     a = a + [n]
     n += 1
for i in range(K):
     d = int(input())
     A = list(map(int,input().split()))
     for j in range(d):
          if A[j] in a:
               a.remove(A[j])
ans = len(a)
print(ans)

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split(' ')))

table = {l for l in range(1, N + 1)}
have = set()

for i in range(K):
    d = int(input())
    nums = list(map(int, input().split(' ')))
    have = have | set(nums)

ans = len(table - have)

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, k = map(int, input().split())

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys

N,K = map(int,input().split())
array = [ a for a in range(1,N+1) ]

for I in range(K):
    _ = input()
    sweets = list(map(int,input().split()))
    for K in sweets:
        if K in array:
            array.remove(K)
print(len(array))

Submission status: Accepted

Solution code:
import itertools
n,k = (int(x) for x in input().split())
a = []
l = []

for i in range(k):
    d = int(input())
    a.append(list(map(int, input().split())))
b = list(itertools.chain.from_iterable(a))

for i in range(1,n+1):
    l.append(i)

ans = set(b)^set(l)
print(len(set(ans)))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
sunuke = [0]*n

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

print(sunuke.count(0))

Submission status: Accepted

Solution code:
def main():
  n, k = map(int, input().split())
  a = set()
  for i in range(k):
    input()
    a |= set(list(map(int, input().split())))
  print(n-len(a))

if __name__ == "__main__":
  main()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
xs = set()
for i in range(k):
    d = int(input())
    xs = xs.union(set(map(int, input().split())))
print(n - len(xs))

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    a = set()
    for i in range(k):
        input()
        a |= set(list(map(int, input().split())))
    print(n-len(a))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
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_1=itertools.chain.from_iterable(a)
print(n-len(list(set(a_1))))

Submission status: Accepted

Solution code:
N, K = (int(x) for x in input().split())
check=[False]*N
ans=N
for i in range(K):
  d=int(input())
  A=list(map(int, input().split()))
  for j in range(d):
    if check[A[j]-1]==False:
      ans-=1
      check[A[j]-1]=True
print(ans)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
a = [list(map(int,input().split())) for i in range(2*K)]
s = []; t = 0
for i in range(K):
    s = s + a[2*i+1]
for i in range(1,N+1):
    if i not in s:
        t+=1
print(t)

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
c = [0] * n

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
D=[]
A=[]
DB=[0]*N

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

for a in A:
    for i in a:
        DB[i-1]+=1

ans=0

for db in DB:
    if db==0:
        ans+=1

print(ans)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def line():
	return [int(i) for i in input().split(" ")]
n, k = line()
vis = [0 for i in range(n)]
for _ in range(k):
	line()
	for i in line():
		vis[i-1] = 1
print(vis.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = 0

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

print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
l = [0] * n
for i in range(k):
    d = int(input())#お菓子の種類
    a = map(int, input().split())  #持っている人
    for j in a:
        l[j-1] += 1

print(l.count(0))

Submission status: Accepted

Solution code:
#import time

def main():
    N, K = map(int, input().split())
    matrix = [list(map(int, input().split())) for i in range(2*K)]
    sunuke = [0]*(N+1)
    for i in range(K):
        for j in matrix[2*i+1]:
            sunuke[j] += 1
    ans = sunuke.count(0) -1

    return ans

if __name__ == '__main__':
    #start = time.time()
    print(main())
    #elapsed_time = time.time() - start
    #print("経過時間:{}".format(elapsed_time * 1000) + "[msec]")

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
sunuke = []

for i in range(n):
    sunuke.append(1)

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

print(sum(sunuke))

Submission status: Accepted

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


sum_A=[]

for i in range(K):
  for j in range(d[i]):
    sum_A.append(A[i][j])

ans = N - len(set(sum_A))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
sunuke = [0] * N
for i in range(K):
    di = int(input())
    Ai = map(int, input().split())
    for a in Ai:
        sunuke[a - 1] += 1
answer = 0
for s in sunuke:
    if s == 0:
        answer += 1
print(answer)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

numbers = input().split(" ")
n = int(numbers[0])
k = int(numbers[1])
have_okashi = [0] * n
r = 0

for i in range(k):
  input()
  numbers = input().split(" ")
  for x in numbers:
    have_okashi[int(x) - 1] = 1


print(have_okashi.count(0)  )

Submission status: Accepted

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

Submission status: Accepted

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

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

s = [1] * n

for an in a:
  for j in an:
    s[j-1] = 0

print(sum(s))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, readline().split())
A_all = []
for i in range(K):
    d = int(readline())
    A = list(map(int,readline().split()))
    A_all += A
set(A_all)
cnt = 0
for i in range(1,N+1):
    if i not in A_all:
        cnt +=1
print(cnt)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
ns = [i for i in range(1,n+1)]
d = []
a = []

for k in range(2*k):
    if k % 2 == 0:
        d.append(int(input()))
    else:
        a.append(list(map(int, input().split())))

a = set(sum(a,[]))
ans = set(ns) - a
print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
s = set()
for i in range(k):
    input()
    s |= set(input().split())#和集合
print(n-len(s))

Submission status: Accepted

Solution code:
n,k=map(int, input().split())
sunuke=[0]*n
for i in range(k):
    d=int(input())
    a_list=[int(i) for i in input().split()]
    for j in range(d):
        sunuke[a_list[j]-1]+=1

print(sunuke.count(0))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
B=[]
for n in range(N):
    B.append(n+1)
for i in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    for n in A:
        if n in B:
            B.remove(n)  
print(len(B))

Submission status: Accepted

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

count = [0]*(n+1)
count1 = 0

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

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

print(count1)

Submission status: Accepted

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

hum_can = [[] for _ in range(n)]

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

print(hum_can.count([]))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


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

    have = [0 for i in range(N)]
    for _ in range(K):
        D = int(input())
        A = list(map(int, input().split()))
        for a in A:
            have[a - 1] = 1

    print(N - sum(have))


def main():
    solve()


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# B Trick or Treat

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

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

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

i=0
A=[]
for a in range(K):
    M=[]
    P=input()
    M= list(map(int, input().split()))
    A=A+M
for b in range(1,N+1):
    if b not in A:
        i+=1

print(i)

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
a = set(range(1,n+1))
for i in range(1,k+1):
    d = int(input())
    a -= {int(i) for i in input().split()}
ans = len(a)
print(ans)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
cc = [1] * n
for _ in range(k):
    d = input()
    lis = list(map(int,input().split()))
    for l in lis:
        cc[l-1] = 0
print(sum(cc))

Submission status: Accepted

Solution code:
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N,K = map(int, input().split())
    having = [False]*(N)
    for _ in range(K):
        d = int(input())
        for a in map(int, input().split()):
            having[a-1] = True

    print(len(list(filter(lambda b: not b, having))))

main()

Submission status: Accepted

Solution code:
import numpy as np

n, k = map(int, input().split())
# お菓子とすぬけの行列(k行n列)
matrix = np.zeros(shape=(k, n))

for row in range(k):
  _ = int(input())
  fn = [int(i) for i in input().split()] 
  for col in fn:
	  matrix[row, col - 1] = 1 # お菓子kをすぬけnが持つかどうかのフラグ

print(np.count_nonzero(matrix.sum(axis=0)==0, axis=0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
a=[]
ans=0
for m in range(1,N+1):
  a.append(0)
for k in range(K):
  d=int(input())
  A=list(map(int,input().split()))
  for i in range(d):
    a[A[i]-1] += 1
for x in range(N):
  if a[x]==0:
    ans +=1
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
cnt = [0] * N
for _ in range(K):
    d = int(input())
    A = [int(x) for x in input().split()]
    for i in range(d):
        cnt[A[i]-1] += 1

print(cnt.count(0))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
s = [0] * n
for i in range(k):
  d = int(input())
  a = map(int, input().split())
  for ad in a:
    s[ad-1] += 1

print(sum(map(lambda x: 1 if x == 0 else 0, s)))

Submission status: Accepted

Solution code:
import collections

N, K = map(int, input().split())
d = []
A = []

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

c = collections.Counter(A)

print(N - len(c.keys()))

Submission status: Accepted

Solution code:
import numpy as np
a,b=map(int,input().split())
c=np.zeros(a)
for i in range(b):
  input()
  x=list(map(int,input().split()))
  for i in x:
    if c[i-1]==0:
      c[i-1]=1
    else:
      pass
print(int(a-sum(c)))

Submission status: Accepted

Solution code:
def getInts():
    return [ int(x) for x in input().split() ]

[N,K] = getInts()
haveSnak = set()
for i in range(K):
    [d] = getInts()
    xs = getInts()
    for x in xs:
        haveSnak.add(x)
count = 0
for i in range(1,N+1):
    if i not in haveSnak:
        count += 1
print(count)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
D = [-1] * k
A = [False] * (n + 1)
A[0] = True
for i in range(k):
    input()
    for j in list(map(int, input().split())):
        A[j] = True
print(A.count(False))

Submission status: Accepted

Solution code:
n,snack=map(int,input().split())
l=[]
for i in range(1,n+1):
  l.append(i)
l=set(l)
for i in range(snack):
  d=int(input())
  t=set(map(int,input().split()))
  l=l-t
print(len(l))

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    sunukes = set()
    for _ in range(k):
        input()
        sunukes |= set(list(map(int, input().split())))
    print(n-len(sunukes))

if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = 0
for j in range(1, N+1):
  if j in A:
    pass
  else:
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
Sunuke=[]

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

    Sunuke.extend(A)

print(N-(len(set(Sunuke))))

Submission status: Accepted

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

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

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

print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
(n, k) = [int(x) for x in input().split()]

s = set()

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

Submission status: Accepted

Solution code:
n, k = (int(i) for i in input().split())

fed_snukes = set()
for d in range(k):
  __ = int(input())
  sn = set(int(i) for i in input().split())
  fed_snukes.update(sn)

print(n - len(fed_snukes))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
l=[]
for i  in range(n):
    l.append(i+1)
for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for z in a:
        if z in l:
            l.remove(z)
print(len(l))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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