n, k =map(int,raw_input().split())
mapping=[]
parts=0
total=0
for i in range(k):
	arr = map(int,raw_input().split())
	x  = arr[1:]
	mapping.append(x)
	temp=0
	for i in range(1,arr[0]):
		if x[i]!=(x[i-1]+1):
			temp+=1
			total+=1
	parts+=(temp)
print parts+total+(k-1)


