n, k = map(int, input().split())
for i in range(k):
	a = list(map(int,input().split()))
	if a[1] == 1:
		have = len(a)-1
		for j in range(1,len(a)):
			if a[j] != j:
				have = j-1
				break
		want = n-1-(have-1)
		print(want - (k-1) + want)
		break
