def open_doll(i):
    global opened, time
    opened[doll_num[i]] = i+1
    time += doll_size[doll_num[i]] - 1 - doll_ind[i]

n, k = [int(i) for i in input().split(" ")]
doll_num, doll_ind, doll_size = [0] * n, [0] * n, [0] * k
opened = [0]*k
time = 0
for i in range(k):
    s_doll = [int(i) for i in input().split(" ")]
    doll_size[i] = s_doll[0]
    for j in range(s_doll[0]):
        doll_num[s_doll[j+1] - 1] = i
        doll_ind[s_doll[j+1] - 1] = j
for i in range(n-1):
    if (doll_num[i] != doll_num[i+1]):
        if not opened[doll_num[i]]:
            open_doll(i)
        if not opened[doll_num[i+1]]:
            open_doll(i+1)
        if opened[doll_num[i+1]] == i+2 and doll_ind[i+1] != 0:
            opened[doll_num[i+1]] = i+1
            time += 1
        time += 1
    elif (doll_num[i] == doll_num[i+1]) and opened[doll_num[i]] > 0 and opened[doll_num[i]] < i+2:
        time += 1
print(time)
        
