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
  
  
  def I():
      return int(input())
  
  
  def MI():
      return map(int, input().split())
  
  
  def LI():
      return list(map(int, input().split()))
  
  
  def main():
      mod = 10**9 + 7
      N, M = MI()
  
      class Lazysegtree:
          # RAQ
          def __init__(self, A, intv, initialize=True, segf=min):
              # 区間は 1-indexed で管理
              self.N = len(A)
              self.N0 = 2 ** (self.N - 1).bit_length()
              self.intv = intv
              self.segf = segf
              self.lazy = [0] * (2 * self.N0)
              if initialize:
                  self.data = [intv] * self.N0 + A + [intv] * (self.N0 - self.N)
                  for i in range(self.N0 - 1, 0, -1):
                      self.data[i] = self.segf(self.data[2 * i], self.data[2 * i + 1])
              else:
                  self.data = [intv] * (2 * self.N0)
  
          def _ascend(self, k):
              k = k >> 1
              c = k.bit_length()
              for j in range(c):
                  idx = k >> j
                  self.data[idx] = (
                      self.segf(self.data[2 * idx], self.data[2 * idx + 1])
                      + self.lazy[idx]
                  )
  
          def _descend(self, k):
              k = k >> 1
              idx = 1
              c = k.bit_length()
              for j in range(1, c + 1):
                  idx = k >> (c - j)
                  ax = self.lazy[idx]
                  if not ax:
                      continue
                  self.lazy[idx] = 0
                  self.data[2 * idx] += ax
                  self.data[2 * idx + 1] += ax
                  self.lazy[2 * idx] += ax
                  self.lazy[2 * idx + 1] += ax
  
          def update(self, k, x):
              k = k + self.N0
              self.data[k] = x
              self._ascend(k)
  
          def query(self, l, r):
              L = l + self.N0
              R = r + self.N0
              Li = L // (L & -L)
              Ri = R // (R & -R)
              self._descend(Li)
              self._descend(Ri - 1)
  
              s = self.intv
              while L < R:
                  if R & 1:
                      R -= 1
                      s = self.segf(s, self.data[R])
                  if L & 1:
                      s = self.segf(s, self.data[L])
                      L += 1
                  L >>= 1
                  R >>= 1
              return s
  
          def add(self, l, r, x):
              L = l + self.N0
              R = r + self.N0
  
              Li = L // (L & -L)
              Ri = R // (R & -R)
  
              while L < R:
                  if R & 1:
                      R -= 1
                      self.data[R] += x
                      self.lazy[R] += x
                  if L & 1:
                      self.data[L] += x
                      self.lazy[L] += x
                      L += 1
                  L >>= 1
                  R >>= 1
  
              self._ascend(Li)
              self._ascend(Ri - 1)
  
      sst = Lazysegtree([0] * (N + 1), 0, True, max)
  
      la = [[] for _ in range(N + 1)]
  
      for i in range(M):
          l, r, a = MI()
          la[r].append([l, a])
  
      # sst[i]はi桁目がビットの立っている最右である時のmax
      # lrのクエリはrまで来た時に，範囲内に加算
  
      for i in range(1, N + 1):
          temp = sst.query(0, i)
          sst.add(i, i + 1, temp)  # とりあえず，[0,i)の最大値を入れておく
  
          for l, a in la[i]:
              sst.add(l, i + 1, a)
  
      print(sst.query(0, N + 1))
  
  
  main()
  
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."}]