mod segment_tree {
    pub struct Lazy<T, E, F, G, H> {
        n: usize,
        k: usize,
        a: Vec<(T, E)>,
        e: T,
        id: E,
        f: F,
        g: G,
        h: H,
    }
    impl<T: Copy, E: Copy, F: Fn(T, T) -> T, G: Fn(T, E) -> T, H: Fn(E, E) -> E> Lazy<T, E, F, G, H> {
        pub fn new(n: usize, e: T, id: E, f: F, g: G, h: H) -> Lazy<T, E, F, G, H> {
            let mut k = 0;
            while (1 << k) < n {
                k += 1;
            }
            Lazy {
                n: 1 << k,
                k: k,
                a: vec![(e, id); 2 << k],
                e: e,
                id: id,
                f: f,
                g: g,
                h: h,
            }
        }
        fn eval (&self, x: usize) -> T {
            (self.g)(self.a[x].0, self.a[x].1)
        }
        fn propagate (&mut self, mut x: usize) {
            x += self.n;
            for k in (1..(self.k + 1)).rev() {
                let y = x >> k;
                self.a[2 * y].1 = (self.h)(self.a[2 * y].1, self.a[y].1);
                self.a[2 * y + 1].1 = (self.h)(self.a[2 * y + 1].1, self.a[y].1);
                self.a[y].1 = self.id;
                self.a[y].0 = (self.f)(self.eval(2 * y), self.eval(2 * y + 1));
            }
        }
        fn save (&mut self, x: usize) {
            let mut k = (x + self.n) >> 1;
            while k > 0 {
                self.a[k].0 = (self.f)(self.eval(2 * k), self.eval(2 * k + 1));
                k >>= 1;
            }
        }
        pub fn update (&mut self, l: usize, r: usize, p: E) {
            self.propagate(l);
            self.propagate(r - 1);
            let mut x = l + self.n;
            let mut y = r + self.n;
            while x < y {
                if (x & 1) == 1 {
                    self.a[x].1 = (self.h)(self.a[x].1, p);
                    x += 1;
                }
                if (y & 1) == 1 {
                    y -= 1;
                    self.a[y].1 = (self.h)(self.a[y].1, p);
                }
                x >>= 1;
                y >>= 1;
            }
            self.save(l);
            self.save(r - 1);
        }
        pub fn find (&mut self, l: usize, r: usize) -> T {
            self.propagate(l);
            self.propagate(r - 1);
            let mut p = self.e;
            let mut q = self.e;
            let mut x = l + self.n;
            let mut y = r + self.n;
            while x < y {
                if (x & 1) == 1 {
                    p = (self.f)(p, self.eval(x));
                    x += 1;
                }
                if (y & 1) == 1 {
                    y -= 1;
                    q = (self.f)(self.eval(y), q);
                }
                x >>= 1;
                y >>= 1;
            }
            (self.f)(p, q)
        }
    }
}

//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        m: usize,
        p: [(usize, usize, i64); m],
    }
    let mut q = vec![vec![]; n + 1];
    for (l, r, a) in p {
        q[r].push((l, a));
    }
    let f = std::cmp::max;
    let g = |a: i64, b: i64| a + b;
    let h = |a: i64, b: i64| a + b;
    let mut s = segment_tree::Lazy::new(n + 1, 0, 0, f, g, h);
    for i in 1..(n + 1) {
        let v = s.find(0, i);
        s.update(i, i + 1, v);
        for &(l, a) in &q[i] {
            s.update(l, i + 1, a);
        }
    }
    let ans = s.find(0, n + 1);
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 37112