[n, k] = map(int, raw_input('').split(' '))
max_value_in_one_sequence = 1
breaks = 0
for i in xrange(k):
    nums = map(int, raw_input('').split(' '))
    if nums[1] == 1:
        i = 2
        while i <= nums[0] and nums[i] == (nums[i - 1] + 1):
            max_value_in_one_sequence = nums[i]
            i += 1
        breaks += (nums[0] - i + 1)
    else:
        breaks += (nums[0] - 1)
ans = (n - max_value_in_one_sequence) + breaks
print ans
