public class ArrayManipulation {
// https://www.hackerrank.com/challenges/crush/problem
public ArrayManipulation() {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int m = scanner.nextInt();
int[] array = new int[n];
for (int i = 0 ; i < m; i++) {
int a = scanner.nextInt() - 1;
int b = scanner.nextInt() - 1;
int k = scanner.nextInt();
for (int j = a; j <= b; j++) {
array[j] += k;
}
}
scanner.close();
// Find max value of array
int maxValue = array[0];
for(int i = 1; i < array.length; i++){
if(array[i] > maxValue){
maxValue = array[i];
}
}
System.out.println(maxValue);
}
}