n,k = map(int, raw_input().split())
op = 0 
for i in xrange(k):
	temp = map(int,raw_input().split())
	c = temp[0]
	chns = temp[1:]
	con = c
	j = 1
	if chns[0] == 1:
		con -= 1
		while j < c and chns[j-1] == chns[j] - 1:
			con -= 1
			j += 1
		op += 2*con	
	else:
		op += 2*con-1
print op
	
