n, m = map(int, raw_input().split())
ans = 2 * n - m - 1
for i in range(m):
    a = map(int, raw_input().split())
    for j in range(1, a[0]):
        if a[j+1] == j+1 and a[j] == j:
            ans -= 2
        else:
            break
print(ans)
