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()
  
      import operator
      from functools import reduce
  
      class LazySegmentTree:
          def __init__(self, values, fn=max):
              """
              :param list values:
              :param callable fn:
              """
              # 単位元
              self._id = 0
              self._size = len(values)
              self._fn = fn
  
              tree = [self._id] * self._size * 2
              tree[self._size :] = values[:]
              for i in reversed(range(1, self._size)):
                  tree[i] = fn(tree[i << 1], tree[i << 1 | 1])
              self._tree = tree
              self._delay = [self._id] * self._size * 2
  
          def _add(self, k, value):
              if k < self._size:
                  self._delay[k] = self._delay[k] + value
              else:
                  self._tree[k] = self._tree[k] + value
  
          def add(self, l, r, value):
              """
              :param int l:
              :param int r:
              :param value:
              """
              l += self._size
              r += self._size
              l0, r0 = l, r
              while l < r:
                  if l & 1:
                      # 右側の子
                      self._add(l, value)
                      l += 1
                  if r & 1:
                      # 左側の子
                      r -= 1
                      self._add(r, value)
                  l >>= 1
                  r >>= 1
              self._update(l0)
              self._update(r0)
  
          def _update(self, p):
              """
              self._tree[p] の親たちを最新化する
              :param int p:
              """
              p >>= 1
              while p > 0:
                  self._tree[p] = self._fn(
                      self._tree[p << 1] + self._delay[p << 1],
                      self._tree[p << 1 | 1] + self._delay[p << 1 | 1],
                  )
                  p >>= 1
  
          def _eval(self, p):
              """
              self._tree[p] に遅延配列から値を移す
              :param int p:
              """
              # root から葉に向かって遅延配列を移していく
              for h in reversed(range(1, p.bit_length())):
                  k = p >> h
                  self._tree[k] = self._tree[k] + self._delay[k]
                  self._add(k << 1, self._delay[k])
                  self._add(k << 1 | 1, self._delay[k])
                  self._delay[k] = self._id
  
          def get(self, l, r=None):
              """
              :param int l:
              :param int|None r:
              """
              if r is None:
                  self._eval(self._size + l)
                  return self._tree[self._size + l]
              ret_l = []
              ret_r = []
              l += self._size
              r += self._size
              self._eval(l)
              self._eval(r)
              while l < r:
                  if l & 1:
                      ret_l.append(self._tree[l])
                      l += 1
                  if r & 1:
                      r -= 1
                      ret_r.append(self._tree[r])
                  l >>= 1
                  r >>= 1
              return reduce(self._fn, ret_l + ret_r)
  
      sst = LazySegmentTree([0] * (N + 3), fn=max)
      lra = [[0, 0, 0] for _ in range(M)]
      lra.append([N + 5, N + 5, 0])  # 番兵
  
      for i in range(M):
          lra[i][0], lra[i][1], lra[i][2] = MI()
  
      lra.sort(key=lambda x: x[1])
  
      # sst[i]はi桁目がビットの立っている最右である時のmax
      # lrのクエリはrまで来た時に，範囲内に加算
  
      now = 0  # クエリ処理用
  
      for i in range(1, N + 1):
          temp = sst.get(0, i)
          # print(i,temp)
          sst.add(i, i + 1, temp)  # とりあえず，[0,i)の最大値を入れておく
          # print(sst.get(i,i+1))
          while i >= lra[now][1]:
              sst.add(lra[now][0], lra[now][1] + 1, lra[now][2])
              # print(i,lra[now][0],lra[now][1]+1,lra[now][2])
              now += 1
          """L=[]
          for j in range(N+1):
              L.append(sst.get(j,j+1))
          print(L)"""
          sst.get(0, N + 2)
  
      print(sst.get(0, N + 2))
  
  
  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."}]