n, m = (int(x) for x in input().split())
coolLen = 1
res = 0
for x in range(m):
	cur = [int(x) for x in input().split()]
	k = cur[0]
	f = cur[1]
	if cur[1] != 1:
		res += len(cur) - 2
	else:
		cur = cur[1:]
		for i in range(len(cur) - 1):
			if cur[i] + 1 != cur[i+1]:
				coolLen = i + 1
				break
		else:
			coolLen = len(cur)
		res += len(cur) - coolLen
res += n - 1 - (coolLen - 1)
print(res)