a,b=map(int,raw_input().split())
l=[]
ans=0
for i in range(b):
    c=map(int,raw_input().split())
    for j in range(0,c[0]-1):
        if (c[j+1]+1)!=c[j+2]:
            ans+=1
            l.append(c[j+2])
print len(l)+ans+(b-1)

