__author__ = 'Andrey'
n, k = map(int, input().split())
ans = 0
for q in range(k):
    chain = list(map(int, input().split()))[1:]
    if chain[0] != 1:
        ans += len(chain) - 1
    else:
        k = 1
        while k < len(chain) and chain[k] == chain[k - 1] + 1:
            k += 1
        ans += len(chain[k - 1:]) - 1
print(ans + n - 1 - k + 1)