n,k = map(int,input().split(" "))
i=0
res=k
sh=0
while i<k:
    i+=1
    mas=list(map(int,input().split(" ")))[1:]


    if mas[0]==1:
         j=0
         while j<(len(mas)-1):

             if(mas[j]+1!=mas[j+1]):
                 break
             else:
                 j+=1
         sh+=len(mas)-j-1
         res+=len(mas)-j-1
    else:
        res+=len(mas)-1
        sh+=len(mas)-1

print(sh+res-1)
