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:]
    kk = 1
    parts += 1
    for el in range(len(pat)-1):
        if pat[el+1] - pat[el] != 1:
            kk+=1
            parts += 1
    ans += kk - 1

print(ans+parts-1)
