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:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N, K = Scanner.map_int()
    M = [False for _ in range(N)]
    for _ in range(K):
        D = Scanner.int()
        A = Scanner.map_int()
        for a in A:
            M[a - 1] = True
    print(sum([not m for m in M]))


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()

Submission status: Accepted

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

for x in c:
    if x == 0:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
import os
import math
import bisect
import collections
import itertools

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    snk = [0] * N
    for n in range(K):
        d = ii()
        A = il()
        for a in A:
            snk[a-1] += 1
    print(sum(1 for s in snk if s == 0))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
x = [1]*n
for _ in range(k):
  di = int(input())
  ai = list(map(int,input().split()))
  for y in ai:
    if x[y-1] == 1:
      x[y-1] = 0
print(sum(x))

Submission status: Accepted

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

li = [1 for i in range(N)]

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

    for j in lis:
        li[j-1]=0

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

Submission status: Accepted

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

S = [0 for i in range(n)]

for i in range(k):
    d = 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())
cnt=[0 for _ in range(n)]
for i in range(k):
    d=int(input())
    a= list(map(int,input().split()))
    for x in a:
        cnt[x-1]+=1
ans=0
for x in cnt:
    if x==0:
        ans+=1
print(ans)

Submission status: Accepted

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

n_list = [0 for _ in range(n)]

for i in range(k):
    d = input()
    target = list(map(int,input().split()))
    for t in target:
        n_list[t-1] = 1

print(len(n_list)-sum(n_list))

Submission status: Accepted

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

answer=0
for nl in nlist:
    if nl==0:
        answer+=1

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum(X))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
l = list(range(1, n+1))

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

ans = 0

for a in A:
    if a == 0:
        ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    n, k = MII()
    snk = [0]*n
    for i in range(k):
        d = II()
        aa = MIIZ()
        for a in aa:
            snk[a] = 1
    z = [1 for s in snk if s == 0]
    print(sum(z))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10**6)
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K, A):
    b = [0] * N
    for a in A:
        for i in a:
            b[i-1] += 1
    return b.count(0)


def main():
    N, K = read_int_n()
    A = []
    for _ in range(K):
        read_int()
        A.append(read_int_n())
    print(slv(N, K, A))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import bisect,sys
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac =fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV
        
    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s+=a
        yield s


sys.setrecursionlimit(200005)


def main():
    N,K = isRaw()
    sRa = []
    for k in range(K):
        d = iRaw()
        As = isRaw()
        sRa+=As
    return N - len(set(sRa))
    
if __name__ == "__main__":
    print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

c = Counter()
N, K = map(int, input().split())
for k in range(K):
    d = int(input())
    As = list(map(int, input().split()))
    for a in As: c[a] += 1
print(N - len(c))

Submission status: Accepted

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

check = [1] * (N + 1)
check[0] = 0

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


print (sum(check))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

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

print(Counter(SNUKE)[0])

Submission status: Accepted

Solution code:
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

n,k = NextInts()
st = set()
for i in range(k):
    d = NextInt()
    da = NextIntList()
    for i in da: st.add(i)
print(n-len(st))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
data = [0]*N
for i in range(K):
    di = int(input())
    ai = list(map(int,input().split()))
    for j in range(di):
        data[ai[j]-1] += 1

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
lst = list(range(1,N+1))
for i in range(K):
    d = int(input())
    A = map(int,input().split())
    for A_ in A:
        if A_ in lst:
            lst.remove(A_)
print(len(lst))

Submission status: Accepted

Solution code:
N, D = map(int, input().split())
none = set(range(1, N+1))
for _ in range(D):
  input()
  none -= set(map(int, input().split()))
print(len(none))

Submission status: Accepted

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

for _ in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for i in a:
        ask.add(i)
print(n - len(ask))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
s = set()
for _ in range(k):
    d = int(input())
    A = list(map(int, input().split()))
    s |= set(A)

print(n-len(s))

Submission status: Accepted

Solution code:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


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

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

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


if __name__ == '__main__':
    main()

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 j in a:
    cnt[j-1] += 1
print(cnt.count(0))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
have = [False]*N
for _ in range(K):
    d = int(input())
    ad = list(map(int,input().split()))
    for i in ad:
        have[i-1] = True
ans = N - sum(have)
print(ans)

Submission status: Accepted

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

ans = useds.count(0)
print(ans)

Submission status: Accepted

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

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

print(N - len(set(snukes)))

Submission status: Accepted

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

for i in range(k):
    d=int(input())
    motteru=[int(i) for i in input().split()]
    for j in motteru:
        a[j-1]+=1
print(a.count(0))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter


def solve():
    n, k = map(int, input().split())
    l = [0 for _ in range(n)]
    for _ in range(k):
        input()
        a = list(map(int, input().split()))
        for i in a:
            l[i-1] += 1
    c = Counter(l)
    print(c[0])


if __name__ == '__main__':
    solve()

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 a in list(map(int, input().split())):
        if a in s:
            s.remove(a)
print(len(s))

Submission status: Accepted

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

print(n - len(ans))

Submission status: Accepted

Solution code:
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N,K = inputlist()
dic = {n:0 for n in range(1,N+1)}

for i in range(K):
    d = int(input())
    A = inputlist()
    for j in range(d):
        dic[A[j]] +=1
ans= 0
for i in range(1,N+1):
    if dic[i] == 0:
        ans +=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input=lambda: sys.stdin.readline().rstrip()
n,k=map(int,input().split())
C=[0]*n
for _ in range(k):
  d=int(input())
  A=[int(i) for i in input().split()]
  for a in A:
    C[a-1]+=1
ans=0
for c in C:
  if c==0:
    ans+=1
print(ans)

Submission status: Accepted

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

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

    print(candy.count(0))


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok

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 a:
        have[j-1] = True

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
li = [False]*N
for i in range(K):
    d = int(input())
    l = list(map(int, input().split()))
    for x in l:
        li[x-1] = True
ans = 0
for i in range(N):
    if not li[i]:
        ans += 1
        
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,k = iim()
l = [True]*n
for i in range(k):
    d = ii()
    A = iil()
    for item in A:
        if l[item-1] == True:
            l[item-1] = False

print(l.count(True))

Submission status: Accepted

Solution code:
#coding: utf-8
N, K = map(int, input().split())
A = [0 for _ in range(N)]
ans = 0
for i in range(K):
    d = int(input())
    tmp = list(map(int, input().split()))
    for j in range(d):
        A[tmp[j]-1] += 1
for i in range(N):
    if A[i] == 0:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()

ans = set(range(1, N+1))
for _ in range(K):
	d = INT()
	A = LIST()
	ans -= set(A)
print(len(ans))

Submission status: Accepted

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

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

    for aa in a:
        has[aa - 1] = 1

print(n - sum(has))

Submission status: Accepted

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

L = [0] * N

for i in A:
  for j in i:
    L[j - 1] = 1

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

print(ans)

Submission status: Accepted

Solution code:

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

retval=0
for s in sunuke:
    if s==0:
        retval+=1
print(retval)

Submission status: Accepted

Solution code:
from sys import stdin
from sys import setrecursionlimit

setrecursionlimit(10 ** 7)

n,k = map(int,stdin.readline().rstrip().split())
se = set()
for i in range(k):
    d = int(stdin.readline().rstrip())
    a = list(map(int,stdin.readline().rstrip().split()))
    for j in a:
        se.add(j)

print(n-len(se))

Submission status: Accepted

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

my_set = set()

for i in range(k):
    _ = int(input())
    my_list = list(map(int, input().split()))
    for item in my_list:
        my_set.add(item)

print(n - len(my_set))

Submission status: Accepted

Solution code:
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, K = map(int, rl().split())
    
    su_set = set()
    for _ in range(K):
        d = int(rl())
        ai = list(map(int, rl().split()))
        for aij in ai:
            su_set.add(aij)
    
    print(N - len(su_set))


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

for _ in range(k):
    d = int(input())
    a = map(int, input().split())
    for a_i in a:
        cnt[a_i] += 1

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

print(ans-1)

Submission status: Accepted

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

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 a in A:
        have[a-1] = True

print(sum([have[i] == False for i in range(n)]))

Submission status: Accepted

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

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 a in A:
        sunuke[a - 1] += 1

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

print(N - len(T))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
a = [False for i in range(N)]
for i in range(K):
	d = int(input())
	A = list(map(int,input().split()))
	for x in A:
		a[x-1] = True
print(sum([0 if x else 1 for x in a]))

Submission status: Accepted

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

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 range(d):
        snuke[A[j]-1] += 1
print(snuke.count(0))

Submission status: Accepted

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

Submission status: Accepted

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

det = [1] * N

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

print(sum(det))

Submission status: Accepted

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

Submission status: Accepted

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

done = set([])
for _ in range(K) :
  d = int(input())
  A = [int(i) for i in input().split()]
  done |= set(A)
  
print(N - len(done))

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
data = []
kind = set(range(1,n+1))
for i in range(k):
    d = int(input())
    li = list(map(int, input().split()))
    for j in li:
        if j in kind:
            kind.remove(j)
print(len(kind))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, K = getlist()
	D = defaultdict(int)
	for i in range(K):
		d = int(input())
		A = getlist()
		for j in A:
			D[j] += 1

	ans = N - len(D)
	print(ans)

if __name__ == '__main__':
	main()

Submission status: Accepted

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

print(sum(x==0 for x in count))

Submission status: Accepted

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

print(sum(p))

Submission status: Accepted

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

from collections import defaultdict
dic = defaultdict(int)


for _ in range(k):
    d = int(input())
    al = list(map(int,input().split()))
    for a in al:
        dic[a] += 1
ans = 0
for i in range(1,n+1):
    if dic[i] == 0:
        ans += 1
print(ans)