def solve(groups):
	first = sorted(groups, key=lambda x: x[0])[0]
	lastVal = 1
	count = 1
	total = 0
	for i in range(1, len(first)):
		if first[i] == lastVal + 1:
			count += 1
			lastVal += 1
		else:
			break
	total += ((len(first) - count) * 2)
	for i in range(len(groups)):
		if groups[i] != first:
			total += len(groups[i]) * 2 - 1
	return total

n1, k1 = map(int, raw_input().split())
groups1 = [map(int, raw_input().split())[1:] for i in range(k1)]
print solve(groups1)