#n = int(input())
n, m = map(int, input().split(" "))
luck = 0
total = 2*n-1 -m

for j in range(m):
    arr = input().split(" ")
    for i in range(1, int(arr[0])+1):
        arr[i] = int(arr[i])
    arr.pop(0)
    if arr[0] == 1:
        prev = 0
        potential = -1
        for i in arr:
            #count luck
            if i == prev+1:
                potential += 1
                prev = i
            else:
                break
        luck += potential
    
print (total - luck*2)
