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()))
n_list=[]
ans_list=[]
for i in range(N):
  ans_list.append(i+1)

for i in range(K):
  d = int(input())
  a_list = list(map(int, input().split()))
  n_list.extend(a_list)
  n_list = list(set(n_list))
print(len(list(set(ans_list)-set(n_list))))

Submission status: Accepted

Solution code:

n,k=map(int,input().split())
a=[]
cnt=0
for i in range(k):
    d=int(input())
    x=[int(e) for e in input().split()]
    for j in x:

        a.append(j)
a.sort()
for j in range(len(a)-1):
    if a[j]!=a[j+1]:
        cnt+=1
print(n-cnt-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
n, k = (int(x) for x  in input().split())
l = []
la = l.append
for _ in range(k):
    input();la(list((int(x)for x in input().split())))
p = set(sum(l, []))
ans = 0
for x in range(1, n+1):
    if x not in p:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:

import sys
s = sys.stdin.readlines()

n, k=map(int, s[0].split())

d=[]
A=[]

for i in s[1:2*k:2]:
    d.append(int(i))

for i in s[2:2*k+1:2]:
    A.append(list(map(int, i.split())))

from collections.abc import Iterable
def flatten(l):
    for el in l:
        if isinstance(el, Iterable) and not isinstance(el, (str, bytes)):
            yield from flatten(el)
        else:
            yield el

A_flat=list(flatten(A))

import collections
c = collections.Counter(A_flat)

print(n-len(list(c.keys())))

Submission status: Accepted

Solution code:
#--Trick or Treat
import itertools

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

A = []
judge = list(range(1,N+1))
for i in range(K):
  d = int(input())
  A.append([int(i) for i in input().split()])

allocate = list(itertools.chain.from_iterable(A))
#print(judge)
#for i in range(1,K):

l1_l2_sym_diff = []
l1_l2_sym_diff = set(allocate) ^ set(judge)
print(len(l1_l2_sym_diff))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

S = range(1, N+1)

for _ in range(K):
    d = int(raw_input())
    A = map(int, raw_input().split())
    for a in A:
        if a in S:
            S.remove(a)

print len(S)

Submission status: Accepted

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

ans=[]
for i in range(1,n+1):
  if i not in(a):
    ans.append(i)
print(len(ans))

Submission status: Accepted

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

d = []
A = []
for i in range(K):
    d_pre = int(input())
    A_pre = [int(x) for x in input().split()]
    d.append(d_pre)
    A.extend(A_pre)

A_unique = list(set(A))

ans = 0

for i in range(1, N+1):
    if i in A_unique:
        pass
    else:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
mem = set()
for _ in range(K):
  _ = input()
  mem = mem | set(map(int, input().split()))

mem_count = len(mem)
print(N-mem_count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = list(map(int, input().split()))
hoge = [1] * n

for i in range(k * 2):
  a = list(map(int, input().split()))
  if i % 2 != 0:
    for j in a:
      hoge[j - 1] = 0
      
print(sum(hoge))

Submission status: Accepted

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

for x in range(K):
    d = int(input())
    snukes = list(map(int,input().split()))
    for i in snukes:
        sozinho[i-1] += 1

print(sozinho.count(0))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
d=list()
array=list()
for i in range(k):
	d.extend(input())
	array.extend(input().split())

print(n-len(set(array)))

Submission status: Accepted

Solution code:
import itertools
N,K = map(int,input().split())
d = list()
A = list()
for _ in range(K):
    d.append(int(input()))
    A.append(list(map(int,input().split())))
A = list(itertools.chain.from_iterable(A))
A = set(A)
print(N-len(A))

Submission status: Accepted

Solution code:
import collections
li=[]
n,k=map(int,input().split())
for i in range(k):
    d=int(input())
    lik=list(map(int,input().split()))
    li+=lik
li=collections.Counter(li)
ans=0
for j in range(1,n+1):
    if li[j]==0:
        ans+=1
print(ans)

Submission status: Accepted

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

d = []
A = []
for k in range(K):
    d_temp = int(input())
    d.append(d_temp)
    a_temp = input().split()
    for a in range(d_temp):
        A.append(int(a_temp[a]))

count = 0
for n in range(N):
    judg = (n+1) in A
    if judg == False:
        count += 1
print(count)

Submission status: Accepted

Solution code:
def resolve():
	n, k = map(int, input().split())
	p = [0]*n
	for _ in range(k):
		input()
		t = list(map(int, input().split()))
		for i in t:
			p[i-1] += 1
	ans = 0
	for i in p:
		if i == 0:
			ans += 1
	print(ans)
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
class abc_166:
    
    def __init__(self):
        pass
    
    def A(self):
        S=input()
        ans= "ARC" if S=="ABC" else "ABC"
        print(ans)
    
    def B(self):
        NK=list(map(int,input().split()))
        d=[]
        A=[]
        
        for i in range(NK[1]):
            d=int(input())
            a = list(map(int,input().split()))
            A.extend(a)
        
        print(NK[0]-len(list(set(A))))  
            
    def C(self):
        pass
    
    def D(self):
        pass
    
    def E(self):
        pass
    
    def F(self):
        pass
    
    
if __name__=='__main__':
    obj=abc_166()
    obj.B()

Submission status: Accepted

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

Submission status: Accepted

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

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():
    nk = input().split(" ")

    d = []
    a = []
    for i in range(int(nk[1])):
        d.append(int(input()))
        a.append(input().split(" "))
        a[i] = [int(s) for s in a[i]]

    l = [0] * (int(nk[0]) + 1)
    
    for i in range(int(nk[1])):
        for j in range(d[i]):
            z = a[i][j]
            l[z] += 1

    count = 0
    for i in l:
        if i == 0:
            count += 1

    print(count - 1)
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
ls = []
for x in range(K*2):
    ls.append(input().split())
ls2 = []
i = 1
while i < K*2:
    for j in ls[i]:
        ls2.append(j)
    i += 2
ls2 = set(ls2)
print(N - len(ls2))

Submission status: Accepted

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

for i in range(K):
    d = int(input())
    a = list(map(int, input().split()))
    [s.add(num) for num in a]

print (N - len(s))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
d=[0 for i in range(K)]
A=[[0 for i in range(N)] for i in range(K)]
B=[]
C=[i+1 for i in range(N) ]
for i in range(K):
    d[i]=int(input())
    A=[0 for i in range(d[i])]
    A=[int(i) for i in input().split()]
    C=list(set(C)-set(A))

print(len(C))

Submission status: Accepted

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

havesweet = []
for num in range(N):
  havesweet.append(0)

for num in range(K):
  d.append(int(input()))
  a.append(list(map(int, input().split())))
  
  for having in a[num]:
    havesweet[having-1] += 1	#入力は1から->0からにする

result = 0
for having in havesweet:
  if having == 0:
    result += 1

print(result)

Submission status: Accepted

Solution code:
N,K=(int(x) for x in input().split())
lists=[0]*N
while 1:
    try:
        tmp=int(input())
    except :
        break
    have_count=(int(x) for x in input().split())
    for i in have_count:
        lists[i-1]=1
print(lists.count(0))

Submission status: Accepted

Solution code:
a,b = map(int, input().split())
List = [list(map(int, input().split())) for i in range(2*b)]
list_all=[]
Output = 0
for i in range(b):
  list_all = list_all+List[2*i+1]
set_a = set(list_all)
Output = a- len(set_a)
print(Output)

Submission status: Accepted

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

Submission status: Accepted

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

for _ in range(N):
    Nlist.append(0)


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

for j in range(K):
    for k in range(d[j]):
        Nlist[A[j][k]-1] += 1

for l in range(N):
    if Nlist[l] == 0:
        B = B + 1

print(B)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
s = set()
for _ in range(k):
    d = int(input())
    a = tuple(map(int, input().split()))
    for _a in a:
        s.add(_a)

print(n - len(s))

Submission status: Accepted

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

d_list = list()
sunuke_idx_set = set()

for i in range(K):
  d_list.append(int(input()))
  sunuke_idx_set |= set(map(int, input().split(' ')))
  
#print(d_list)
#print(sunuke_idx_set)

print(N - len(sunuke_idx_set))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
sunuke=[]
for i in range (0,N):
    sunuke.append(i+1)
for k in range (0,K):
    a=int(input())
    b=list(map(int,input().split()))
    for j in range (0,a):
        if b[j] in sunuke:
            sunuke.remove(b[j])
print(len(sunuke))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
g=[int(o) for o in range(1,n+1)]
for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for j in range(1,n+1):
        if a.count(j)>=1 and g.count(j)==1:
            g.remove(j)
print(len(g))

Submission status: Accepted

Solution code:
N, K = [int(v) for v in input().split()]
trick_flags = [True] * N
for i in range(K):
    d = int(input())
    A = [int(v) for v in input().split()]
    for a in A:
        trick_flags[a - 1] = False
print(sum(trick_flags))

Submission status: Accepted

Solution code:
import itertools
import numpy as np
N,K=map(int,input().split())
count=0
sunuke=[]
sweets=[]
for i in range(1,N+1):
    sunuke.append(i)
while(1):
    d=int(input())
    A=list(map(int,input().split()))
    sunuke=list(set(sunuke)-set(A))
    count+=1
    if count==K:
        break
print(len(sunuke))

Submission status: Accepted

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

have = set(a)

print(n - len(have))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
d=[0 for i in range(k+1)]
a=[[0 for i in range(101)] for i in range(k+1)]
for i in range(1,k+1):
    d[i]=int(input())
    l = list(input().split())
    for j in range(1,d[i]+1):
        a[i][j]=int(l[j-1])
lis=[i for i in range(1,n+1)]
for i in range(1,k+1):
    for j in range(1,d[i]+1):
        for m in lis:
            if a[i][j]==m:
                try:
                    lis.remove(m)
                except:
                    continue
print(len(lis))

Submission status: Accepted

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

l=[0]*N

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

  
print(l.count(0))

Submission status: Accepted

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

list = []
for i in range(1,n+1):
    list.append(i)
for risu in num_list:
    for x in risu:
        if x in list:
            list.remove(x)
tuple = tuple(list)


print(len(tuple))

Submission status: Accepted

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

for i in range(k):
  j = int(input())
  ls = list(input().split())
  anslist |=set(ls)

#print(anslist)  
print(n-len(anslist))

Submission status: Accepted

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

for j in range(1, N+1):
  if j in A:
    pass
  else:
    B.append(j)
print(len(B))

Submission status: Accepted

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

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

count = 0
for i in A:
    if i == 0:
        count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    masterArray = []
    for i in range(K):
        _ = input()
        haveNumber = list(map(int, input().split()))
        masterArray.extend(haveNumber)
    result = set(masterArray)
    print(N - len(result))


if __name__ == "__main__":
    # execute only if run as a script
    main()

Submission status: Accepted

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

s0 = set([i for i in range(1,N+1)])
s1 = set()

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

    for j in range(d[i]):
        s1.add(A[i][j])

s_diff = s0 - s1

print(len(s_diff))

Submission status: Accepted

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

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

ans = N
A = sum(A, [])
for i in range(1,N+1):
    if i in A:
        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=A+a
s=0
for i in range(1,N+1):
  if i not in A:
    s+=1
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
a = []
for i in range(N):
    a.append(0)
for i in range(K):
    d_i = int(input())
    A_i = list(map(int,input().split()))
    for k in range(N):
        if (k+1 in A_i) == True :
            a[k] =a[k] + 1
sum = 0
for i in range(N):
    if a[i] == 0:
        sum += 1
print(sum)

Submission status: Accepted

Solution code:
from itertools import chain

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

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
A = []
for i in range(K) :
    d = int(input())
    A.append(input().split(" "))
    
snukeList = []
for i in range(len(A)) :
    for j in range(len(A[i])) :
        snukeList.append(int(A[i][j]))
count = 0
for i in range(1, N+1) :
    if i in snukeList :
        continue
    count += 1
print(count)

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.append(a)

ref = A[0]

for i in range(1, K):
  ref = list(set(ref) & set(A[i])) + list(set(ref) ^ set(A[i]))

len = len(ref)

print(N - len)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
arr = []
n,k= list(map(int,readline().rstrip().split()))
for i in range(k):
  s = readline()
  t = readline().rstrip().decode().split()
  arr.extend(t)

print(n-len(set(arr)))

Submission status: Accepted

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

for i in range(K):
  d=int(input())
  a=list(map(int, input().split()))
  for j in range(d):
    S[a[j]-1]=1
print(len([i for i,x in enumerate(S) if x==0]))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(m.count(0))

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 += a
A_ = set(A)
print(n - len(A_))

Submission status: Accepted

Solution code:
li = list(map(int, input().split()))
N, K = li[0], li[1]
d = []
A = []
for i in range(K):
    d.append(input())
    A.append(list(map(int, input().split())))
sunuke = list(range(1, N+1))
treated = []
for Ai in A:
    for x in Ai:
        if x not in treated:
            treated.append(x)
tricked = list(set(sunuke) - set(treated))
print(len(tricked))

Submission status: Accepted

Solution code:
import collections
s=[]
a=[]
S =  list(map(int,input().split()))
N = S[0]
K = S[1]
for i in range(1,K+1):
    d = int(input())
    A = list(map(int,input().split()))
    a.append(A)
for t in range(1,N+1):
    s.append(t)
import itertools
aa=list(itertools.chain.from_iterable(a))
c = collections.Counter(aa)
print(len(s)-len(c))

Submission status: Accepted

Solution code:

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


c=sum(A, [])
c=set(c)
NN=len(c)
ans=N-NN
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
inputs = []
while True:
  try:
    inputs.append(input())
  except EOFError:
    break

# print(inputs)

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

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

print(people - len(having_snacks))

Submission status: Accepted

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

Submission status: Accepted

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

A = [-1] * n

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for number_of_candies in range(k):
    d = int(input())
    sunuke_list = map(int, input().split())
    for sunuke in sunuke_list:
        safe_sunuke_set.add(sunuke)

print(n - len(safe_sunuke_set))

Submission status: Accepted

Solution code:

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

d = []
a = []

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

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

Submission status: Accepted

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

data = [[0 for i in range(k)] for j in range(n)]

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

    for m in a:
        data[m - 1][i] = 1

dd = []

for d in data:
    dd.append(sum(d))

ans = 0

for ddd in dd:
    if ddd == 0:
        ans += 1

print(ans)

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:
N,K=map(int, input().split(" "))
d=[0]*K
A=[0]*K
dic={}
for i in range(K):
    d[i]=int(input())
    A[i]=input().split()
for j in range(K):
    if d[j]==1:
        if A[j][0] not in dic:
                dic[A[j][0]]=1
    if d[j]!=1:
        for k in range(d[j]):
            if A[j][k] not in dic:
                dic[A[j][k]]=1
print(N-len(dic))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = input().split()
sunuke = {}

for i in range(1, int(n)+1):
  sunuke[i] = sunuke.get(i, 0)

for i in range(0, int(k)):
  okashi = input()
  mochi = list(map(int, input().split()))
  for j in range(0, len(mochi)):
    sunuke[mochi[j]] += 1

count = 0
for key, value in sunuke.items():
    if value == 0:
        count += 1
print(count)

Submission status: Accepted

Solution code:
n , k = map(int , input().split())
done = set()
for i in range(k):
	c = int(input())
	arr = list(map(int , input().split()))
	for ele in arr:
		done.add(ele)
ans = 0
for i in range(1,n+1):
	if i not in done:
		ans+=1
print(ans)

Submission status: Accepted

Solution code:
N,K = map(int,input().split(' '))
A_list = []
count = 0
for i in range(K):
    di = int(input())
    Ai = list(map(int,input().split(' ')))
    [A_list.append(A) for A in Ai]
set_a = set(A_list)
count = N - len(set_a)
print(count)

Submission status: Accepted

Solution code:
N,K = map(int,input().split(" "))
trickSum = 0
result = list()
for i in range(K):
    d = input()
    result = result + (list(map(int, input().split(" "))))
print(N - len(set(result)))

Submission status: Accepted

Solution code:
n, k =map(int,input().strip().split())
ans=[0]*n
for i in range(k):
    store=int(input())
    li = list(map(int,input().strip().split()) )
    for k in range(len(li)):
        ans[li[k]-1]=1

print(ans.count(0))

Submission status: Accepted

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

list1 = [0]*N
for i in range(K):
    d = int(input())
    haved = input().split()
    for j in haved:
        arg = int(j)-1
        list1[arg] += 1
print(list1.count(0))

Submission status: Accepted

Solution code:
import sys
def inpl(): return list(map(int, sys.stdin.readline().split()))

x = inpl()
N = []
cnt = 0
for i in range(0, x[0]):
    N.append(0)

for i in range(0, x[1]):
    tem = int(input())
    A = inpl()

    for j in range(0, tem):
        N[A[j]-1] += 1

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

print(cnt)

Submission status: Accepted

Solution code:
N, K = input().split()
d = []
x2 = []
count = 0
for i in range(0, int(N)):
  x2.append(0)
for i in range(0, int(K)):
  d = int(input())
  x = input().split()
  for j in x:
    if x2[int(j)-1] == 0:
      x2[int(j)-1] = 1
      count += 1
print(int(N)-count)

Submission status: Accepted

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

for i in range(k):
    d=int(input())
    b=list(map(int, input().split()))
    for j in range(d):
        try:
            a.remove(b[j])
        except ValueError:
            pass

print(len(a))

Submission status: Accepted

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

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

count = 0
for i in range(N):
  if List_All.count(List[i]) == 0:
    count += 1

print(count)

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    d_list = []
    Ai_list = []
    dict = {}
    b_list = []
    for i in range(0,K) :
        d = int(input())
        d_list.append(d)
        A_list = [A for A in input().split()]
        A_list = list(map(int, A_list))
        dict[d] = A_list
        b_list.extend(A_list)
        A_list = []

    b_list = list(set(b_list))
    print (N - len(b_list))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
c = []
for i in range(b):
    d = int(input())
    c.append([d, list(map(int, input().split()))])
e = 0
for i in range(1, a+1):
    for j in c:
        if i in j[1]:
            break
    else:
        e += 1
print(e)

Submission status: Accepted

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

Submission status: Accepted

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

sunukes = []

for i in range(K):
    _ = int(input())
    p = list(map(int, input().split()))
    
    for j in range(len(p)):
        if p[j] not in sunukes:
            sunukes.append(p[j])

n = 0

for i in range(N):
    if i+1 not in sunukes:
        n += 1

print(n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import re

N, K = map(int, input().split())
A = sys.stdin.readlines()
#改行コード削除
A = [b.strip() for b in A]

l_temp = []
for i in range(K*2):
  if i % 2 == 0:
    d = A[i]
    ary = A[i+1].split()
    for item in ary:
      l_temp.append(item)

print(N - len(list(set(l_temp))))

Submission status: Accepted

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

arr = [ 1 for x in range ( N ) ] ;
for x in range ( K ) :
	r = input() ;
	for x in map( int, input().strip().split(" ") ) :
		arr[x-1] = 0 ;
print ( sum( arr ) ) ;

Submission status: Accepted

Solution code:
import itertools
import collections

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

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

array = list(itertools.chain.from_iterable(a))
c = collections.Counter(array)

print(n - len(c))

Submission status: Accepted

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

for i in range(n):
    sun.append(0)

for i in range(k):
    d=int(input())
    tmp=list(map(int,input().split()))
    for j in tmp:
        sun[j-1]=sun[j-1]+1
    
ans=0

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


print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=list(map(int,input().split()))
b,c=[],[]
ans=set()
for _ in range(a[1]):
    b.append(int(input()))
    c.append(list(map(int,input().split())))
for i in range(a[1]):
    for j in range(b[i]):
        ans.add(c[i][j])
print(a[0]-len(ans))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
s=[1]*n
for c in range(k):
    d=int(input())
    a=[int(x)-1 for x in input().split()]
    for b in a:
        s[b]=0
print(sum(s))