n, k = map(int, raw_input().split())
A = [map(int, raw_input().split())[1:] for _ in xrange(k)]

cost = 0
for a in A:
	old = 0
	for i, k in enumerate(a):
		if i == 0:
			if k > 1:
				cost += 1
		else:
			if k - 1 > old:
				cost += 2
		old = k
print cost
