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:
        if c[v]:
            i = 0
            while i + 1 < len(c[v]) and c[v][i] + 1 == c[v][i+1]:
                i += 1
            if i > 0:
                r += len(c[v]) - i - 1
            else:
                r += len(c[v])
    else:
        r += len(c[v])

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