I = lambda: map(int,raw_input().split())
n, k = I(); ans = 2 * n - k - 1
for _ in xrange(k):
    m = I()
    for x in xrange(1,m[0]):
        if m[x] == x and m[x+1] == x+1:
            ans -= 2
        else:
            break
print ans