n, k = map(int, raw_input().split())
a = [map(int, raw_input().split()) for _ in xrange(k)]
res = 0
for x in a:
    if x[1] != 1:
        res += x[0] - 1
    else:
        i = 1
        while i < x[0] and x[i]+1 == x[i+1]:
            i += 1
        res += x[0] - i
        res += n - i
print res
