import sys
l = sys.stdin.readline().split()
n = int(l[0])
k = int(l[1])

m = []
for i in xrange(k):
	m.append(sys.stdin.readline().split())

alrea = 0
res = 0
for line in m:
	if int(line[1]) == 1:
		j = 1
		while j < len(line):
			if int(line[j]) == j:
				j += 1
			else:
				break
		alrea = j -1
		res += int(line[0]) - alrea
	else:
		res += int(line[0]) - 1

print res + n - alrea