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())

sunuke = [0]*n

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

print(sunuke.count(0))

Submission status: Accepted

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

for i in range(K):
    tmp = int(input())
    tmp_list = list(map(int, input().split()))
    person += tmp_list

print(N-len(set(person)))

Submission status: Accepted

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

Submission status: Accepted

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

snacks = []
for i in range(k):
    d = int(input())
    snack = list(map(int, input().split()))
    ssnack = []
    for j in range(d):
        ssnack.append(snack[j]-1)
    snacks.append(ssnack)

marks = [1 for i in range(n)] # お菓子を持っていなければ1
for i in snacks:
    for j in i:
        marks[j] = 0


print(str(sum(marks)))

Submission status: Accepted

Solution code:
n,k = (int(x) for x in input().split())
sunuke = [True] * n
for i in range(k):
    c = int(input())
    ar = [int(x) for x in input().split()]
    for v in ar:
        sunuke[v - 1] = False

ans = 0
for v in sunuke:
    if v == True:
        ans +=1

print(ans)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a=[list(map(int,input().split())) for _ in range(2*k)]
b=[]
for i in range(k):
  b += a[2*i+1]
c=set(b)
print(n-len(c))

Submission status: Accepted

Solution code:
S = list(map(int,input().split()))
counter = 0
nuske = []

for k in range(S[0]):
  nuske.append(int(0))

for i in range(S[1]):
  roop = int(input())
  if roop == 1:
    temp = int(input())
    nuske[temp-1] = nuske[temp-1] + 1
  else:
    temp = list(map(int,input().split()))
    for l in temp:
      nuske[l-1] = nuske[l-1] + 1

for y in nuske:
  if y == 0:
    counter += 1
print(counter)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())

n, k = ISI()
l = [1] * n
for i in range(k):
	input()
	a=ILI()
	for j in a:
		l[j-1]=0
print(sum(l))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
p = [0 for _ in range(n+1)]
for _ in range(k):
  d = int(input())
  for a in list(map(int, input().split())):
    p[a] += 1
print(len(list(filter(lambda x:x==0, p[1:]))))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    n, k = map(int, input().split())
    flag = [1 for i in range(n)]
    for i in range(k):
        d = int(input())
        Sunukes = list(map(int, input().split()))
        for sunuke in Sunukes:
            flag[sunuke-1] = 0
    print(sum(flag))
resolve()

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
arr=[]
ans=[str(i) for  i in range(1,N+1)]
for i in range(K):
    _=input()
    arr.extend((input().split()))
    arr=list(set(arr))
p=0
for n  in  ans:
    if(not(n in arr) ) :
        p=p+1
print(p)

Submission status: Accepted

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

C = set(x +1 for x in range(N))
for i in range(K):
    d = int(input())
    A = [int(x) for x in input().split()]
    for x in A:
        if x in C:
            C.remove(x)
print(len(C))

Submission status: Accepted

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

for i in range(k):
    _ = input().rstrip()
    l = list(map(int, input().rstrip().split()))
    for v in l:
        pl[v - 1] += 1

r = sum(v == 0 for v in pl)
print(r)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
all = set(i for i in range(1,n+1))
tr = set()
for _ in range(k):
    d = int(input())
    for i in input().split():
        tr.add(int(i))
sa = all - tr
print(len(sa))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
l = [list(map(int,input().split())) for i in range(2*K)]#一行ずつ格納
d = []
A = []
for i in range(K):
    d.append(l[2*i][0]) #Aiの長さ
    A.append(l[2*i +1]) #A[お菓子i][を持っているすぬけ君]

having = [0]*N #各すぬけ君の所持お菓子カウント
for i in range(K): #お菓子i
    for j in range(d[i]):
        having[A[i][j]-1] += 1
        
ans = 0
for i in range(N):
    if having[i] == 0:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
d = [0]*n  # 0 * n個分の要素数の配列を作成 ex. [0, 0, 0, 0, .....]
for _ in range(k):
    input()
    l = (list(map(int, input().split())))
    for i in l:
        d[i - 1] = 1  # 0を1に変更する

print(d.count(0))  # 0の要素の個数をカウント

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

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

print(n-len(set(li)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

treat = 0

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

Submission status: Accepted

Solution code:
try:
    n,k=map(int, input().split())
    arr=[]
    for i in range(k):
        d=int(input())
        arr.extend(map(int,input().split()))
    check=set(arr)
    ans=n-len(check)
    print(ans)
except EOFError as e:
    pass

Submission status: Accepted

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

print(N-len(set(l)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
n,k=map(int,input().split())
sunuke=np.zeros(n,dtype=int)
for i in range(k):
    number=input()
    data=list(map(int,input().split()))
    for j in data:
        sunuke[j-1]=1
print(np.count_nonzero(sunuke==0))

Submission status: Accepted

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

print(n - len(set(ans)))

Submission status: Accepted

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

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

	hasSnack += InputA

print(len(list(set(allSunuke) - set(hasSnack))))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k = map(int, readline().split())
ans = set()
cnt = 0
for _ in range(k):
    d = int(readline())
    a = list(map(int, readline().split()))
    ans |= set(a)
for i in range(n):
    if (i + 1) not in ans:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
n,k=[int(_) for _ in input().split()]
s=set()
for a in range(k):
    x=int(input())
    y=[int(_) for _ in input().split()]
    for b in y:
        s.add(b)
print(len(set(range(1,n+1))-s))

Submission status: Accepted

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

#すぬけ君の人数分の要素をもったリストを作成する
#１にするのは、最終的に和をとって人数を算出するため

treat = [1]*n

#すぬけ君の人数分の要素をもったリストを作成する

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

#お菓子を持っているすぬけ君をリストtreat上で１から0にする
#リスト番号は「入力-1」となるので、以下のようにする

  for j in a:
    treat[j-1] = 0

#リスト上で１になっているモノの和が、いたずらされる人数

print(sum(treat))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    N, K = [int(i) for i in input().strip().split()]
    no_sweet_members = set(range(1, N+1))
    for i in range(K):
        d = int(input().strip())
        member = [int(i) for i in input().strip().split()]
        for m in member:
            if m in no_sweet_members:
                no_sweet_members.remove(m)

    return len(no_sweet_members)


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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

items = []

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

print(N - len(set(items)))

Submission status: Accepted

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

sunukes = list()
for i in range(1,n+1):
    sunukes.append(i)

sunukes = set(sunukes)

for i in range(1,k+1):
    input()
    sunukes = sunukes - set(map(int,input().split()))

print(len(sunukes))

Submission status: Accepted

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


l = set()
d = [input().split() for _ in range(k*2)]
for i in range(len(d)):
	if i % 2 == 1:
		l = l | set(d[i])
print(n - len(l))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
Data = [0]*N
for k in range(K):
    _ = input()
    user = list(map(int,input().split()))
    for u in user:
        Data[u-1] += 1
ans = 0
for i in range(N):
    if Data[i] == 0:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
temp=input().split(' ')
N=int(temp[0])
K=int(temp[1])

flag=[1 for n in range(N)]

for k in range(K):
  d=int(input())
  A=input().split(' ')
  for a in A:
    flag[int(a)-1]=0

ans=sum(flag)
print(ans)

Submission status: Accepted

Solution code:
#166-B（Trick or Treat）

#Input
Inputs = []
Input = input().split()

N = Input[0]
N = int(N)
Person = []
for l in range(N):
    Person.append(l+1)

K = Input[1]
K = int(K)
K2 = K * 2
Inputs.append(Input)

for l in range(K2):
    Input = input().split()
    Inputs.append(Input)

#Check
for a in range(K):
    A = (a + 1)*2 
    L = Inputs[A - 1][0]
    L = int(L)
    for b in range(L):
        P = Inputs[A][b]
        P = int(P)
        if P in Person:
            Person.remove(P)

#Output
print(len(Person))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split()]
A = [[] for _ in range(N)]
for i in range(K):
    a = int(input())
    b = input().split()
    for j in range(a):
        A[int(b[j])-1] = 1
j = 0
for i in range(len(A)):
    if A[i] != 1:
        j += 1
print(j)

Submission status: Accepted

Solution code:
import sys
from collections import deque
import numpy as np
import copy
def main():
    N, K = map(int, input().split())
    dp = np.zeros(N)
    count = 0 
    for i in range(K):
        d = int(input())
        A = [int(t) - 1 for t in input().split()]
        for u in range(d):
            dp[A[u]] += 1
    for i in range(N):
        if dp[i] == 0:
            count += 1
    print(count)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

#お菓子を持っていない : 1
#お菓子を持っている   : 0
#持っていない人を最終的に導くから
S = [1] * N 

for i in range(K):
    d = int(input())
    t = map(int, input().split())
    for i in t:
        #i-1なのは添字と要素tが1ぶんずれているから
        S[i-1] = 0
print(sum(S))

Submission status: Accepted

Solution code:
n,k = [int(x) for x in input().split(' ')]
 
def solve(n, k):
    snukes = [None] * n
    victims = 0
    
    for i in range(k):
        snacks = int(input())
        snukes_snacks = [int(z) for z in input().split(' ')]
        for j in range(snacks):
            snukes[snukes_snacks[j] - 1] = snukes_snacks[j]
    
    for w in range(n):
        if snukes[w] is None:
            victims += 1
    
    print(victims)
 
solve(n, k)

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    people = [True for i in range(n)]
    for i in range(k):
        d = int(input())
        for j in map(lambda x: int(x)-1, input().split()):
            people[j] = False
    print(sum(people))
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = [int(i) for i in input().strip().split()]
result = {}
for _ in range(k):
    input()
    for i in input().strip().split():
        result[i] = 1
print(n - len(result))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def solve(string):
    n, k, *da = map(int, string.split())
    t, i = [True] * n, 0
    for _ in range(k):
        d = da[i]
        for j in da[i + 1:i + 1 + d]:
            t[j - 1] = False
        i += d + 1
    return str(sum(t))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
d = []
A = []
s = [1] * N
for k in range(K):
  d.append(int(input()))
  A.append([int(i) for i in input().split()])
  
for k in range(K):
  for n in range(1, N+1):
    if n in A[k]:
      if s[n-1] == 1:
        s[n-1] = 0
print(sum(s))

Submission status: Accepted

Solution code:
# B. Trick or Treat
# https://atcoder.jp/contests/abc166/tasks/abc166_b

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

S = set()
for _ in range(k):
  _ = input()
  S |= set(map(int, input().split()))

print(n - len(S))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
snuke = [i+1 for i in range(n)]
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    snuke = list(filter(lambda x: x not in a, snuke))
print(len(snuke))

Submission status: Accepted

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

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

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

print(len(res))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
victim = [True] * n
for _ in range(k):
    input()
    for a in map(int, input().split()):
        victim[a - 1] = False
print(sum(victim))

Submission status: Accepted

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

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

# print(lst)
print(sum(lst))

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    nk = input()
    nk = nk.split()
    n = int(nk[0])
    k = int(nk[1])

    d = []
    A = []

    for i in range(k):
        d_element = input()
        d_element = int(d_element)
        d.append(d_element)
        A_element = input()
        A_element = A_element.split()
        A_element = list(map(int,A_element))
        A.append(A_element)

    s = set()
    for i in range(len(A)):
        for j in range(len(A[i])):
            s.add(A[i][j])

    ans = n - len(s)
    print(ans)

Submission status: Accepted

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

li = []
for i in range(k*2):
    d_or_k = list(map(int, input().split()))
    if i % 2 != 0:
        li.extend(d_or_k)

li = list(set(li))
print(n - len(li))

Submission status: Accepted

Solution code:
import itertools

inp2intlist = lambda inp:list(map(int,inp))

N,K = list(map(int, input().split(" ")))
A = list(itertools.chain.from_iterable([inp2intlist(input().split())  for i in range(K) if input().split()]))

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

Submission status: Accepted

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

for _ in range(K):
    _ = int(input())
    treat = list(map(int, input().split()))
    for a in treat:
        a -= 1
        have_treat[a] = False
print(sum(have_treat))

Submission status: Accepted

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

snukes = [1]*N

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

    for i in A:
        snukes[i-1] = 0

print(sum(snukes))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
d_list, a_list = [], []
ans_list = [1] * n

for i in range(k):
    d_list.append(int(input()))
    a_list = list(map(int, input().split()))
    for j in a_list:
        if ans_list[j-1] == 1:
            ans_list[j-1] = 0
print(sum(ans_list))

Submission status: Accepted

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

for _ in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    
    for Ai in A:
        flag[Ai-1] = True

print(flag.count(False))

Submission status: Accepted

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

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

print(sum(ans_list))

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())))

cnt = {}
for i, Ai in enumerate(A):
    for j, Aij in enumerate(Ai):
        key = str(Aij)
        cnt.setdefault(key, 0)
        cnt[key] += 1

ans = 0
for i in range(1, N + 1):
    key = str(i)
    cnt.setdefault(key, 0)
    ans += int(cnt[key] == 0)

print(ans)

Submission status: Accepted

Solution code:
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 += A

a = list(set(a))
check = [1] * n
for i in a:
  check[i-1] = 0
print(sum(check))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = tuple(map(int,input().split()))
ans = [1]*n
for i in range(k):
  d = int(input())
  a_i = tuple(map(int,input().split()))
  for a_ij in a_i:
    ans[a_ij-1] = 0
    
print(sum(ans))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    N,K=map(int,input().split())
    S=[0]*N
    for i in range(K):
        d=int(input())
        A=list(map(int,input().split()))
        for i in range(len(A)):
            S[A[i]-1]+=1
    
    print(S.count(0))

    
resolve()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)


def input():
    return sys.stdin.readline()[:-1]


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

print(A.count(0))

Submission status: Accepted

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

print(sum(snuke))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

n, k = [int(x) for x in input().split()]
flag = [1]*n
for _ in range(k):
    d = int(input())
    a = [int(x) for x in input().split()]
    for i in a:
        flag[i - 1] = 0
ans = 0
for j in flag:
    ans += j
print(ans)

Submission status: Accepted

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

print(dp.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in range(K):
    for item in A[i]:
        if item in sunuke:
            continue
        sunuke.append(item)

result = N - len(sunuke)
print(result)

Submission status: Accepted

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


sunuke=[False]*n
for i in range(len(a)):
    for j in range(len(a[i])):
        sunuke[a[i][j]-1] = True
print(sunuke.count(False))

Submission status: Accepted

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

Submission status: Accepted

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

check = [0] * N

for i in range(K):
    d_i = int(input())
    A_i = map(int, input().split())
    for j in A_i:
        check[j-1] = 1

print(sum(1 for x in check if x == 0))

Submission status: Accepted

Solution code:
N, K = [int(x) for x in input().split()]
d = []
Snuke = [0] * N#最終的に0をもつインデックスがいたずらされる．
for k in range(K):
    d.append(input())
    A = [int(a) for a in input().split()]
    for a in A:
        Snuke[a - 1] += 1
count = 0
for i in Snuke:
    if i == 0:
        count += 1
print(count)

Submission status: Accepted

Solution code:
#B
import numpy as np
N, K = map(int,input().split())
A = np.array([0]*N)
for i in range(K):
    d = input()
    have = list(map(int,input().split()))
    for a in have:
        A[a-1] += 1
print(len(A[A==0]))

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

candy = [0] * N

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

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

print(count)

Submission status: Accepted

Solution code:
# ABC166B

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

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

Submission status: Accepted

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

d=[]
sunu = set()

for i in range(k):
    d.append(int(input()))
    dummy = [int(e) for e in input().split()]
    dummy = set(dummy)
    sunu = sunu.union(dummy)
print(n-len(sunu))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
S = set()
for _ in range(K):
    d = int(input())
    S = S.union({int(x) for x in input().split()})
print(N-len(S))

Submission status: Accepted

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

ans = [False] * N
for i in range(K):
    for j in range(d[i]):
        ans[A[i][j] - 1] = True

res = 0
for i in range(N):
    if not ans[i]:
        res += 1;

print(res)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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())))

visited = [False] * N
for i in range(K):
    for j in range(d[i]):
        visited[A[i][j]-1] = True

print(visited.count(False))

Submission status: Accepted

Solution code:
n,k =map(int,input().split())
result=list(range(1,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 result:
            b=result.pop(result.index(a[j]))
print(len(result))

Submission status: Accepted

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

for i in range(K):
  d.append(int(input()))
  manko = list(map(int, input().split()))
  A.extend(manko)
  #print(d)
  #print(A)

A = list(set(A))
#print(A)

L = len(A)
print(N-L)

Submission status: Accepted

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

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())))

bu = [0 for i in range(n)]
for a_ in a:
    for _ in a_:
        bu[_-1]+=1

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
lis = [0 for i in range(n)]
for turn in range(k):
  nn = int(input())
  li = list(map(int,input().split()))
  for num in li:
    lis[num-1] = 1
print(lis.count(0))

Submission status: Accepted

Solution code:
from collections import Counter

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

l = []
counter = 0

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

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

print(counter)

Submission status: Accepted

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

result = [0]*N
ans = 0

for i in range(K):
  p = input()
  tmp = list(map(int, input().split()))
  #print(tmp)
  
  for j in tmp:
    result[j-1] = 1
  
for i in result:
  if i == 0:
    ans += 1

print(ans)

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())))

all_sunuke = set(list(range(1, N+1)))
sunuke = set()

for k in range(K):
    sunuke |= set(A[k])

result = len(all_sunuke - sunuke)

print(result)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
human = [-1 for _ in range(N)]
for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for i in range(d):
        human[A[i]-1] = 1

print(human.count(-1))

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))