def main():
    n, k = map(int, raw_input().split())
    count = 0
    contiguous = 0
    for i in range(k):
        arr = map(int, raw_input().split())
        nums = arr[1:]
        if nums[0] == 1:
            for j in range(len(nums)):
                if nums[j] == j + 1:
                    contiguous += 1
                else:
                    break
            count += arr[0] - contiguous
        else:
            count += arr[0] - 1

    print count + n - contiguous

if __name__ == "__main__":
    main()
