def find_long(a):
    res=0
    idx=0
    print(a)
    for i in range(len(a)):
        prev=a[i][1]
        l=1
        for j in range(2,len(a[i])):
            if prev+1!=a[i][j]:
                break
            prev=a[i][j]
            l+=1
        if l>res:
            res=l
            idx=i
    return res,idx
n,k=map(int,input().split())
a=[]
for _ in range(k):
    a.append([])
for j in range(k):
    a[j]=list(map(int,input().split()))
lres,idx=find_long(a)
cost=0
for i in range(len(a)):
    if i!=idx:
        cost+=len(a[i])-2
print(cost+n-lres)