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 = list(map(int, input().split()))

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

sunuke = [0] * (n)

for i in a:
    for j in i:
        #print(j)
        sunuke[j-1] += 1
#print (sunuke)

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

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

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

s = [0] * N

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

    for num in A:
        s[num-1] += 1
print(s.count(0))

Submission status: Accepted

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

D=[0]*N

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


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

print(cnt)

Submission status: Accepted

Solution code:
sunuke,var = map(int,input().split())
loser = [1] * sunuke
for i in range(var):
  d = int(input())
  tmp = map(int,input().split())
  for t in tmp:
    loser[t-1] = 0
print(sum(loser))

Submission status: Accepted

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

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

print(v.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

sunuke = [0] * n

for candy in a:
    for i in candy:
        i -= 1
        sunuke[i] += 1

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
l1 = [0]*N
for _ in range(K):
    d = int(input()) 
    l2= list(map(int, input().split()))
    for val in l2:
        l1[val-1] = 1
print(N-sum(l1))

Submission status: Accepted

Solution code:
import math

def main():
    a, b = map(int, input().split())
    array = []
    for _ in range(b):
        c = int(input())
        d = list(map(int, input().split()))
        array = array + d


    print(a - len(set(array)))





if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    n, k = map(int, input().split())
    a = []
    for i in range(k):
        d = int(input())
        ai = list(map(int, input().split()))
        a = a + ai
 
    print(n-len(set(a)))
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# 166 B

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

print(n-len(set(l)))

Submission status: Accepted

Solution code:
N,K=(map(int,input().split()))
a=[i for i in range(1,N+1)]
d=[]
A=[]
b=[]
count=0
for i in range(K):
    d.append(int(input()))
    A.append(list(map(int,input().split())))
for i in A:
    for j in i:
        b.append(j)
b1=list(dict.fromkeys(b))
for i in b1:
    if i in a:
        count+=1
print(N-count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
lst=[True for _ in range(n)]

for j in range(k):
    d=int(input())
    l=map(int,input().split())
    for x in l:
        if lst[x-1]:lst[x-1]=False 
print(lst.count(True))

Submission status: Accepted

Solution code:
import math  # noqa: F401
from typing import Dict, List, Optional, Set, Tuple, Union  # noqa: F401


def main(N: int, K: int, D: List[int], A: List[List[int]]) -> None:
    ans: Set[int] = {i for i in range(1, N + 1)}
    for a in A:
        for a_ in a:
            ans -= {a_}
    print(len(ans))


if __name__ == "__main__":
    N, K = map(int, input().split())
    D = []
    A = []
    for _ in range(K):
        d = int(input())
        D.append(d)
        a = list(map(int, input().split()))
        A.append(a)
    main(N, K, D, A)

Submission status: Accepted

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

result = [0 for i in range(N)]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():

    N, K = map(int, input().split())
    have = set()
    for _ in range(K):
        d = input()
        have |= set(list(map(int, input().split())))

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


if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

a = [input() for i in range(2 * k)]
b = a[1:2*k:2]
y=[]
for i in b:
  x = i.split()
  y.extend(x)

b=[]
d=1
while d <= 100:
  b.append(str(d))
  d+=1

c = 0

for i in b:
  if i in y:
    c += 1

c = n - c
print(c)

Submission status: Accepted

Solution code:
arr = list(map(int, input().split()))
n,k = arr[0], arr[1]
arr2 = []
for i in range(0, n):
  arr2.append(i+1)

di = []
snax = []
  
for i in range(0, k):
  temp = []
  di.append(int(input()))
  temp = list(map(int, input().split()))
  for i in temp: snax.append(i)

count = 0
  
for i in arr2:
  if not(i in snax): count+= 1
    
print(count)

Submission status: Accepted

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

print(n - len(set(A)))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
kouho = set(range(1, n + 1))
#print(kouho)
for kashi in range(1, k + 1):
  a = input()
  lst = map(int, input().split())
  for b in lst:
    kouho.discard(b)
print(len(kouho))

Submission status: Accepted

Solution code:
n,k=map(int, input().split())
nl=list(range(1,n+1))
dl=[]
al=[]
for i in range(k):
  d=int(input())
  dl.append(d)
  a = list(input().split())
  a = [int(i) for i in a]
  al.append(a)
  
for i in range(k):
  if len(nl) == 0:
    print(0)
    exit()
  for ii in al[i]:
    if ii in nl:
      nl.remove(ii)
print(len(nl))

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

print(n - len(set(c)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=[int(i) for i in input().split()]
sunuke=[0]*N
for k in range(K):
    dk=int(input())
    A=[int(i) for i in input().split()]
    for a in A:
        sunuke[a-1]+=1
    
n=sum([a==0 for a in sunuke])
print(n)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
A = [input() for _ in range(2*k)]
num = []
list1 = []

for i in range(1, 2*k, 2):
  num = A[i].split()
  list1 += num

print(n - len(set(list(list1))))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
  n, k = map(int, input().split())
  
  kids = list()
  sum = 0
  
  for i in range(k):
    dustbox = input()
    kids += list(map(int, input().split()))
    
  for i in range(1, n+1):
    if i not in kids:
      sum += 1
      
  print(sum)
  
main()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
kids = list()
for i in range(k):
    d = input()
    kids += list(map(int, input().split()))
res = 0
for i in range(1,n+1):
    if i not in kids:
        res+= 1
print(res)

Submission status: Accepted

Solution code:
# B - Trick or Treat
N,K = map(int,input().split())
lis = [1]+[0]*N
for _ in range(K):
    d = int(input())
    A = map(int,input().split())
    for x in A:
        lis[x] += 1
print(len([x for x in lis if x==0]))

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=list(itertools.chain.from_iterable(A))

count = 0
for i in range(n):
    if i+1 not in A:
        count +=1

print(count)

Submission status: Accepted

Solution code:
import numpy as np
def cumsum(x):
    return list(np.cumsum(x))

def cumsum_number(N,K,x):
    ans=[0]*(N-K+1)
    number_cumsum = cumsum(x)
    number_cumsum.insert(0,0)
    for i in range(N-K+1):
        ans[i]=number_cumsum[i+K]-number_cumsum[i]
    return ans
"""
int #整数
float #小数

#for
for name in fruits: #fruitの頭から操作
    print(name)

#リスト
list0 = [] #リスト生成
list0 = [1,2,3,4] #初期化
list0 = [0]*10 #[0,0,0,0,0,0,0,0,0,0]
list1= [i for i in range(10)] #>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
list1 = list(map(int, input().split()))　# 複数の入力をリストに入れる
number=[int(input()) for i in range(int(input()))] #複数行の入力をリストに
list1 = list1 + [6, 7, 8] #リストの追加
list2.append(34) #リストの追加　最後に（）内が足される
list.insert(3,10) #リストの追加　任意の位置（追加したい位置,追加したい値）
len(list4) #リストの要素数
max(sa) #list saの最小値
list5.count(2) #リスト(文字列も可）内の2の数
list1.sort() #並び替え小さい順
list1.sort(reverse=True)  #並び替え大きい順
set(list1) #list1内の重複している要素を削除し、小さい順に並べる
sum([2,3,   ,3]) #リストの合計

abs(a) #aの絶対値
max(a,b) min(a,b) #最大値　最小値
text1 = text1.replace("34","test") #text1内の"34"を"test"に書き換える(文字列内の文字を入れ替える)

exit(0) #強制終了

cumsum(リスト) #累積和をリストで返す
cumsum_number(N,K,x) #N個の数が含まれるリストx内のK個からなる部分和をリストで返す
"""
N,K=map(int,input().split())
number=[1]*N
for i in range(K):
    A=int(input())
    number1=map(int,input().split())
    for j in number1:
        number[j-1]=0
print(number.count(1))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
d=[]
a=set()
for i in range(k):
    nu=int(input())
    d.append(nu)
    m=set(map(int,input().split()))
    a |=m
    
b=set()
for i in range(1,n+1):
    b |= {i}

count=0
for v1 in b:
    if not v1 in a:
        count+=1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  ## IMPORT MODULE
  #import sys

  #sys.setrecursionlimit(100000)
  #input=lambda :sys.stdin.readline().rstrip()

  #f_inf=float("inf")
  #MOD=10**9+7
  
  if 'get_ipython' in globals(): 
    ## SAMPLE INPUT
    n, k = 3, 2
    D = [2, 1]
    A = [[1, 3], [3]]

  else:
    ##INPUT 
    #n = input()
    n, k = map(int, input().split())
    D = [0]*k
    A = []
    for i in range(k):
      D[i] = int(input())
      A.append(list(map(int, input().split())))

  ## SUBMITION CODES HERE
  cnt = 0
  ans = []
  for a in A:
    for i in a:
      if i not in ans:
        ans.append(i)
  print(n-len(ans))
  
main()

Submission status: Accepted

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

result = {}

for i in range(K):
    # お菓子の種類は不要
    input()
    for d in input().split(' '):
        result[d] = True

print(N - len(result))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

ans = list(set(N)-set(A))

print(len(ans))

Submission status: Accepted

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

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

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

ans = list(set(N)-set(A))

print(len(ans))

Submission status: Accepted

Solution code:
from collections import Counter
N, K = map(int, input().split())
xd=[]
for i in range(K):
    d = int(input())
    x = list(map(int, input().split()))
    xd.extend(x)

xd= Counter(xd)

print(N-len(xd))

Submission status: Accepted

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

Submission status: Accepted

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

print(n-sum(ans))

Submission status: Accepted

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

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

A_set=list(set(A_list))

n=N-len(A_set)
print(n)

Submission status: Accepted

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

d = []
a = []

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

print(sum(ans))

Submission status: Accepted

Solution code:
import numpy as np
n,k = map(int,input().split())
sunuke_number = [0]*n
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in range(len(a)):
        sunuke_number[a[j]-1] = 1
print(sunuke_number.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(len(a)):
        ans[a[j]-1] += 1
print(ans.count(0))

Submission status: Accepted

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

print(count.count(0))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().rstrip().split())
sunuke = [int(i) for i in range(1,N + 1)]
d = []
A = []

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

for k in range(K):
  for i in range(d[k]):
    if A[k][i] in sunuke:
      sunuke.remove(A[k][i])
  
    
print(len(sunuke))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
d = []
l = [True] * N

for i in range(K):
    di = int(input())
    # d.append(di)
    Ai = [j-1 for j in map(int, input().split())]
    for j in Ai:
        l[j] = False

# print(N, K)
# for i in range(K):
#     print(d[i])
#     print(A[i])
print(l.count(True))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

print(have.count(False))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
check=[0]*(N+1)
for i in range(K):
  d=int(input())
  A=list(map(int,input().split()))
  for j in A:
    check[j]+=1
ans=0
for i in range(1,N+1):
  if check[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.extend(list(map(int, input().split())))

a_set = set(a)

a_set = list(a_set)

print(n - len(a_set))

Submission status: Accepted

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

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

Submission status: Accepted

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

count=[0]*(n)

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

Submission status: Accepted

Solution code:
import numpy as np

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

trick = np.ones(N, dtype=bool)

for _ in range(K):
    _ = input()
    Index = list(map(lambda x: int(x)-1, input().split(" ")))
    trick[Index] = False

print(np.sum(trick))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def resolve():
	N, K = map(int, input().split())
	a = []*K
	for i in range(K*2): # 開始、終端、ステップ
		if i%2 == 0:
			_ = input()
		else:
			a.extend(list(map(int, input().split())))
	print(N - len(set(a)))

resolve()

Submission status: Accepted

Solution code:
# input() to take in input
n, k = map(int, input().split())

cnt = [0] * n

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

print(cnt.count(0))

Submission status: Accepted

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

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

print(li.count(0))

Submission status: Accepted

Solution code:
n,k=map(int,input().split(' '))
s=set([i+1 for i in range(n)])

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split(' '))
S = set([i + 1 for i in range(N)])

for _ in range(K):
    input()
    S -= set(map(int, input().split(' ')))

print(len(S))

Submission status: Accepted

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

check = []

for k in range(K):
    for i in range(d[k]):
        if A[k][i] not in check:
            check.append(A[k][i])

count = 0

for n in range(N):
    if n+1 not in check:
        count += 1
        
print(count)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
sunuke = list(range(1, n+1))
d = []

for i in range(k):
    d.append(int(input()))
    a_temp = (list(map(int, input().split())))
    for t in a_temp:
        if t in sunuke:
            sunuke.remove(t)

print(len(sunuke))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N , K = map(int,input().split())
sunukes = [1 for _ in range(N)]
for _ in range(K):
  d = input()
  owner_list = [int(i) for i in input().split()]
  for owner in owner_list:
    sunukes[owner-1] = 0
print(sum(sunukes))

Submission status: Accepted

Solution code:
import sys 
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def Main():
    n,k = IL()
    s = [0]*n
    d = deque()
    for __ in range(k):
        d = I()
        tmp = deque(LI())
        for _ in range(d):
            s[tmp.pop()-1] += 1
    print(s.count(0))
    return

if __name__=='__main__':
    Main()

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
DA = [list(map(int, input().split())) for i in range(2*k)]

ANS = []
for i in range(k):
  ANS = ANS + DA[2*i+1]

print(n - len(list(set(ANS))))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(0,K):
    d = input()
    a = list(map(int, input().split()))
    s_list.append(a)

num = len(set(sum(s_list,[])))
print(N-num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

N, K = ri_()
a = [1] * N
for _ in range(K):
    d = ri()
    A = ri_()
    for i in A:
        a[i - 1] = 0
print(sum(a))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
kli=[i+1 for i in range(k)]
L=[]
for i in range(k):
    x=int(input())
    li=list(map(int,input().split()))
    for j in li:
        L.append(j)
L=set(L)
print(n-len(L))

Submission status: Accepted

Solution code:
[N,K]=list(map(int, input().split()))
dlist=[]
alist=[]
for i in range(K):
    d=int(input())
    dlist.append(d)
    alist.append(list(map(int, input().split())))
nlist=[n for n in range(1,N+1)]
ans=0
for n in range(1,N+1):
    flg=True
    for als in alist:
        if n in als:
            flg=False
            break
    if flg:
        ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def trick_or_treat():
    condition = input()
    c_list = condition.split()
    N = int(c_list[0])
    K = int(c_list[1])
    get_list = []
    for k in range(0, K):
        d = int(input())
        A_str = input()
        A_list_s = A_str.split()
        #A_list = []
        for i in A_list_s:
            #A_list.append(int(i))
            get_list.append(int(i))
    
    get_list.sort()
    sunuke_list = []
    for i in range(1, N+1):
        sunuke_list.append(i)
    
    get_list = list(set(get_list))
    num = len(sunuke_list) - len(get_list)
    print(num)
    return      

trick_or_treat()

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
d = []
A = []
count = [0]*N
count.insert(0,'X')

for i in range(K):
	d.append(input())
	A.append(list(map(int,input().split())))
	
for s in range(len(A)):
	for t in range(len(A[s])):
		count[A[s][t]] += 1

print(count.count(0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
sunukes = [0]*N
for i in range(K):
  d = input()
  A = list(map(int, input().split()))
  for snack in A:
    sunukes[snack-1] += 1
ans=0
for total in sunukes:
  if total == 0:
    ans+=1
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
li = [0 for i in range(N)]
for i in range(K):
  d  = int(input())
  li1 = list(map(int, input().split()))
  for j in li1:
    li[j-1] = 1
print(N-sum(li))

Submission status: Accepted

Solution code:
import numpy as np
def resolve():
    N,K = map(int,input().split())
    ans = np.ones(N,dtype=int)
    for i in range(K):
        d = int(input())
        A = input().split()
        for j in range(d):
            ans[int(A[j]) - 1] = 0
    print(sum(ans))
resolve()

Submission status: Accepted

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

ans = n
p = []

for i in range(k):
    for j in a[i]:
        if not j in p:
            p.append(j)
            ans -= 1

print(ans)

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))
flags = [False] * n
count = 0

for i in range(k):
  d = int(input())
  people = list(map(int, input().split()))
  for p in people:
    flags[p - 1] = True
for flag in flags:
  if not flag:
    count += 1
print(count)

Submission status: Accepted

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

S = set(range(1, N+1))

for _ in range(K):
  d = int(input())
  for i in input().split():
    S.discard(int(i))

print(len(S))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
sweet = [0 for i in range(N)]
for i in range(K):
  s = input()
  for j in map(int, input().split()):
    sweet[j-1] = 1
cnt = 0
for k in sweet:
  if k == 0:
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
n, k =map(int, input().split())  #複数数値入力
d = []
a = []
for i in range(k):
    d.append(int(input()))
    ai = list(map(int, input().split()))  #リスト入力
    a.append(ai)
a = sum(a, [])
a = list(set(a))

aset = list(set(a))

result = 0
for i in range(1,n+1):
    if i in aset:
        continue
    else:
        result += 1

print(result)

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    S = [0] * N
    for _ in range(K):
        d = int(input())
        A = [int(a) for a in input().split()]
        for a in A: S[a-1] += 1
    print(S.count(0))

    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
m = {x: False for x in range(1, N + 1)}
for _ in range(K):
    _ = input()
    for x in input().split():
        m[int(x)] = True

print(sum([1 for x in m.values() if x == False]))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
A=[0]*N
for i in range(2*K):
    if i%2==0:
        input()
    else:
        for a in list(map(int,input().split())):
            A[a-1]+=1
print(A.count(0))