output_description: Print the maximum possible score of a string.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N M
      l_1 r_1 a_1
      l_2 r_2 a_2
      :
      l_M r_M a_M
attempt: import sys
  
  input = sys.stdin.readline
  N, M = map(int, input().split())
  a = []
  imos = [0] * (N + 1)
  ls = [N] * (N + 1)
  rs = [0] * (N + 1)
  
  
  t = [[] for _ in range(N + 1)]
  for _ in range(M):
      l, r, c = map(int, input().split())
      a.append((l, r, c))
      imos[l - 1] += c
      imos[r] -= c
      ls[r - 1] = min(ls[r - 1], l - 1)
      rs[l - 1] = max(rs[l - 1], r)
  
  for i in range(N):
      rs[i + 1] = max(rs[i + 1], rs[i])
  for i in range(N, 0, -1):
      ls[i - 1] = min(ls[i - 1], ls[i])
  
  for i in range(N):
      imos[i + 1] += imos[i]
  
  
  # print(ls, rs)
  class SegTree:
      def segfunc(self, x, y):
          return max(x, y)
  
      def __init__(self, n, ide_ele, init_val):
          #####単位元######
          self.ide_ele = ide_ele
          # num:n以上の最小の2のべき乗
          self.num = 2 ** (n - 1).bit_length()
          self.seg = [self.ide_ele] * 2 * self.num
          # set_val
          for i in range(n):
              self.seg[i + self.num - 1] = init_val[i]
          # built
          for i in range(self.num - 2, -1, -1):
              self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2])
  
      def update(self, k, x):
          k += self.num - 1
          self.seg[k] = x
          while k + 1:
              k = (k - 1) // 2
              self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2])
  
      def query(self, p, q):
          if q <= p:
              return self.ide_ele
          p += self.num - 1
          q += self.num - 2
          res = self.ide_ele
          while q - p > 1:
              if p & 1 == 0:
                  res = self.segfunc(res, self.seg[p])
              if q & 1 == 1:
                  res = self.segfunc(res, self.seg[q])
                  q -= 1
              p = p // 2
              q = (q - 1) // 2
          if p == q:
              res = self.segfunc(res, self.seg[p])
          else:
              res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
          return res
  
  
  # print(a)
  seg = SegTree(N + 1, 0, [0] * (N + 1))
  for i in range(N + 1):
      q = seg.query(0, ls[i])
      seg.update(i, max(imos[i] + q, seg.query(ls[i], i)))
      # print(imos[i], q, seg.query(ls[i], i))
  print(seg.query(0, N))
  
problem_description: Statement
  
  Consider a string of length N consisting of `0` and `1`. The score for the
  string is calculated as follows:
  
    * For each i (1 \leq i \leq M), a_i is added to the score if the string contains `1` at least once between the l_i-th and r_i-th characters (inclusive).
  
  Find the maximum possible score of a string.
samples: [{"input": "5 3\n    1 3 10\n    2 4 -10\n    3 5 10", "output": "20\n    \n\nThe score for `10001` is a_1 + a_3 = 10 + 10 = 20.\n\n* * *"}, {"input": "3 4\n    1 3 100\n    1 1 -10\n    2 2 -20\n    3 3 -30", "output": "90\n    \n\nThe score for `100` is a_1 + a_2 = 100 + (-10) = 90.\n\n* * *"}, {"input": "1 1\n    1 1 -10", "output": "0\n    \n\nThe score for `0` is 0.\n\n* * *"}, {"input": "1 5\n    1 1 1000000000\n    1 1 1000000000\n    1 1 1000000000\n    1 1 1000000000\n    1 1 1000000000", "output": "5000000000\n    \n\nThe answer may not fit into a 32-bit integer type.\n\n* * *"}, {"input": "6 8\n    5 5 3\n    1 1 10\n    1 6 -8\n    3 6 5\n    3 4 9\n    5 5 -2\n    1 3 -6\n    4 6 -7", "output": "10\n    \n\nFor example, the score for `101000` is a_2 + a_3 + a_4 + a_5 + a_7 = 10 + (-8)\n+ 5 + 9 + (-6) = 10."}]