n,k=map(int,raw_input().split())
ans=0
group=0
z=[]
for i in xrange(k):
    u=map(int,raw_input().split())[1:]
    u.sort()
    z.append(u)
z.sort()
for u in z:
    if u[0]==1:
        group+=1
        for i in xrange(1,len(u)):
            if u[i]!=i+1:
                ans+=len(u)-i
                group+=len(u)-i
                break
    else:
        ans+=len(u)-1
        group+=len(u)
print ans+group-1
    
        
