I = lambda:map(int,raw_input().split())
n,k = I()
x = k
s = 0 

for i in range(k):
    lst = list(I())
    s = s + len(lst) - 2
    x = x + len(lst) - 2
    if lst[1] == 1:
        for j in range(2,len(lst)):
            if lst[j] == j:    
                x = x - 1
                s = s - 1


print x+s-1

                
              