a = raw_input().split(" ")
(n, c) = (int(a[0]), int(a[1]))
L = [map(int, raw_input().split(" ")) for _ in xrange(c)]
x = n - 1
for i in xrange(c):
    x += L[i][0] - 1
    if L[i][0] >= 2:
        for j in xrange(L[i][0]- 1):
            if L[i][j + 2] - L[i][j + 1] == 1:
                x -= 2
            else:
                break
print x
 