parts = 0
ans = 0
a, b = map(int, input().split(' '))
for i in range(b):
    shw = list(map(int, input().split(' ')))
    ded = shw[0]
    pat = shw[1:]
    if pat[0] == 1:
        ones = 0
        for i in range(ded):
            if pat[i] == i+1:
                ones += 1
        
    parts += ded - 1

print(parts+a-1-(ones-1)*2)
