n, k =map(int,raw_input().split())
mapping=[]
parts=0
total=0
for j in range(k):
	arr = map(int,raw_input().split())
	x  = arr[1:]
	mapping.append(x)
	if arr[0]==0:
		parts+=1
		# continue
	elif 1 not in x:
		total+=(len(x)-1)
		parts+=(len(x))
		# continue
	else:
		f=0
		for i in range(1,arr[0]):
			if x[i]!=(x[i-1]+1):
				f=1
				parts+=1
				parts+=(len(x[i:]))
				total+=(len(x[i:]))
				break
		if f==0:
			parts+=1
	# print parts,total

	# temp=0
	# for i in range(1,arr[0]):
	# 	if x[i]!=(x[i-1]+1):
	# 		temp+=1
	# 		total+=1
	# parts+=(temp+1)
print parts+total-1


