n, m = map(int, raw_input().split())

ans = n - 1
groups = []
for _ in xrange(m):
    group = map(int, raw_input().split())[1:]
    # print group
    ans += len(group) - 1
    # print ans
    if 1 in group:
        for i in xrange(1, len(group)):
            if group[i] == group[i - 1] + 1:
                ans -= 2
            else:
                break
        # print ans
print ans
