using System;
using System.Collections.Generic;
namespace atcoder3
{
public struct iseki
{
public int l, r, s;
}
class MainClass
{
public static void Main (string[] args)
{
var list = new List<iseki>();
string[] str = Console.ReadLine ().Split (' ');
int N = int.Parse (str [0]);
int M = int.Parse (str [1]);
for (int i = 0; i < N; i++) {
str = Console.ReadLine ().Split (' ');
iseki tmp;
tmp.l = int.Parse (str [0]);
tmp.r = int.Parse (str [1]);
tmp.s = int.Parse (str [2]);
list.Add (tmp);
}
int[] sum = new int[M];
for (int i = 0; i < M; i++) {
sum [i] = 0;
}
for (int i = 0; i < M; i++) {
for (int j = 0; j < list.Count; j++) {
if (list [j].l <= (i+1) && list [j].r >= (i+1)) {
;
} else {
sum [i] += list [j].s;
}
}
}
int max = 0;
for (int i = 0; i < M; i++) {
if (max < sum [i]) {
max = sum [i];
}
}
Console.WriteLine ("{0}",max);
}
}
}