n, m = map(int, input().split())
c = {}
r = 0

for _ in range(m):
    t = list(map(int, input().split()))
    c[t[1]] = t[2:]

d = list(c.keys())

for v in d:
    if v == 1:
        i = -1
        if c[v]:
            i = len(c[v]) - 1
        while i > 1 and c[v][i] == c[v][i-1] + 1:
            i -= 1
            r += 1
    else:
        r += len(c[v])

print(len(d) + r * 2 - 1)
