n, k = list(map(int, input().split()))
time = n-1
chains = []
for i in range(k):
    chain = list(map(int, input().split()))
    time += chain[0]-1
    chain = chain[1:]
    for y in range(1, len(chain)):
        if chain[y] != chain[y-1]+1:
            time -= (y-1)+(y-1)
            break
        elif y == len(chain)-1 and chain[y] == chain[y-1]+1:
            time -= y+y
    chains.append(chain)
print(time)
