1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
k, n1 = (int(x) for x in input().split())
p = n1
w = 0
prev_n = n1

for _ in range(1, k):
    dp = 0
    line = [int(x) for x in input().split()]
    ni, meet_list = line[0], line[1:]
    cont_list = [0 for _ in range(prev_n)]
    new_roots = 0
    for i in range(ni):
        if meet_list[i] > 0:
            cont_list[meet_list[i] - 1] += 1
        else:
            new_roots += 1
    for i in range(prev_n):
        if cont_list[i] > 0:
            dp += cont_list[i] - 1
        else:
            w += 1
    if w > new_roots:
        w -= new_roots
    else:
        dp += new_roots - w
        w = 0
    prev_n = ni
    p += dp

print(p)