def arr_inp(n):
    if n == 1:
        return [int(x) for x in stdin.readline().split()]
    elif n == 2:
        return [float(x) for x in stdin.readline().split()]
    else:
        return [str(x) for x in stdin.readline().split()]


from sys import stdin

n, k = arr_inp(1)
arr, ans = [arr_inp(1) for i in range(k)], 0
for i in range(k):
    for j in range(2, arr[i][0] + 1):
        if arr[i][j] - arr[i][j - 1] > 1:
            ans += 1

print(ans + ans + (k - 1))
