import sys
sys.setrecursionlimit(1000000000)

n,k=map(int,input().split())
t=[]
x=0
for i in range(k):
	s=input().split()
	h=[]
	for j in range(len(s)-1):
		h+=[int(s[j+1])]
		if int(s[j+1])==1:x=i
	t+=[h]
	
v=1
bb=True
while bb and len(t[x])>v:
	if t[x][v]==t[x][v-1]+1:v+=1
	else:bb=False
m=len(t[x])-v+(n-len(t[x]))-(k-1)+(n-v)

print(m)
