N,k = map(int,raw_input().split())
arr = []
sz =[]
ht = [0]*(N+1)
for z in xrange(k):
    n = [int(i) for i in raw_input().split()]
    x=n[0]
    n.pop(0)
    sz+=[x]
    for j in n:
        ht[j]=z
    arr += [n]
ti = 0
val = 0
xy = ht[1]
while(len(arr[xy])!=0 and arr[xy][0]==val+1):
    val+=1
    arr[xy].pop(0)
if(len(arr[0])!=0):
    ti+=1
while(val!=N):
    i=ht[val+1]
    ti+=2
    xy=1
    arr[i].pop(0)
    val+=1
    if(len(arr[i])==0):
        ti-=1
print ti
