@staticmethod
def c():
    (n, m, *lrs) = map(int, sys.stdin.read().split())
    (l, r, s) = np.array(lrs).reshape(n, 3).T
    score = np.zeros(((m + 1),), dtype=np.int32)
    np.add.at(score, (l - 1), s)
    np.subtract.at(score, r, s)
    np.cumsum(score, out=score)
    print((s.sum() - score[:m].min()))
@staticmethod
def c():
    (n, m, *lrs) = map(int, sys.stdin.read().split())
    (l, r, s) = np.array(lrs).reshape(n, 3).T
    score = np.zeros(((m + 1),), dtype=np.int32)
    np.add.at(score, (l - 1), s)
    np.subtract.at(score, r, s)
    np.cumsum(score, out=score)
    print((s.sum() - score[:m].min()))