n,k = input().split()
n = int(n)
k = int(k)
#k = int(input())
A = [[]]
b = []
#A = [[] * n] * k
for i in range(k):
    b = input().split()
    b.append(0)
    b = [int(x) for x in b]
    A.append(b)
ans = 0
f = 0 
for i in range(1,k+1):
    lenA = 0
    for h in A[i]:
        if h > 0: lenA += 1
    lenA -= 1
    lenODD = 0
    if lenA%2: lenODD = 1
    else: lenODD = 0
    #print('len ',lenA)
    if A[i][1] != 1:
        ans += lenA - 1
        #print ('ans in if ',ans)
    else:
        j = 2
        if lenA >= 2:
          while A[i][j] - A[i][j-1] == 1 and A[i][j]:
             j += 1
          ans += lenA - (j - 2)-1
          f = j - 2
    #print ('ans after ', ans)
ans += n - f - 1
print(ans)    
