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
y = 0
for i in xrange(c):
    x += L[i][0] - 1
    if L[i][1] == 1:
        j = 2
        while (j <= L[i][0]):
            if L[i][j] == j:
                y += 2
                j += 1
            else:
                break
print x - y
