#include <bits/stdc++.h>

using namespace std;
typedef long long ll ;
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define pb push_back

struct ob {
	unsigned long long t,m ;
} ;

bool comp(ob a , ob b)
{
	return a.t<b.t ;
}

int main()
{
	unsigned long long n,c,x,y,z ;
	cin>>n>>c ;
	vector<ob> a ;
	rep(i,0,n)
	{
		cin>>x>>y>>z ;
		ob t,t1 ;
		t.t=x ; t.m=z ;
		a.pb(t) ;
		t1.t=y+1 ; t1.m=-z ;
		a.pb(t1) ;
	}
	sort(a.begin(),a.end(),comp) ;
	
	unsigned long long t=1 , val=0 , ans=0 , last=0,tmp;
	rep(i,0,a.size())
	{
		if(a[i].t!=t)
		{
			ans += min(c,val)*(a[i].t-t) ;
			t=a[i].t ;
		}
		val += a[i].m ;
	}
	cout<<ans<<endl ;
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define sz(v) (v).size()
#define all(v) (v).begin(),(v).end()
#define REP(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define Time (double)clock()/CLOCKS_PER_SEC
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pi;
template <class T> void chmax(T &x,T y) {x=x>y?x:y;return;}
template <class T> void chmin(T &x,T y) {x=x<y?x:y;return;}
template <class T> T sqr(T x) {return x*x;}
template <class T> T gcd(T x,T y) {return y==0?x:gcd(y,x%y);}
template <class T> T lcm(T x,T y) {return x/gcd(x,y)*y;}
const int inf=1000000000,mod=1000000007;
const ll infll=1000000000000000000ll,modll=ll(mod);
const db maxdb=db(infll),eps=1e-14,PI=acos(-1.0);
//#define mydef
//#define LOCAL
#ifdef mydef
#define foreach(v,it) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#endif
#define debug
#define putnum(x) cout<<#x<<": "<<x<<endl
#define putvec(v) cout<<#v<<": ";REP(i,0,sz(v)) cout<<v[i]<<" ";cout<<endl
template <class T> inline void read(T &x){
	T w=1;x=0;char c=getchar();
	while(c<'0'||c>'9') {if(c=='-')w=-1;c=getchar();}
	while(c>='0'&&c<='9') {x=(x<<3)+(x<<1)+(c&15);c=getchar();}
	x*=w;
}
template <class T> inline void write(T x) {
	if(x<0) putchar('-'),x=~x+1;
	if(x) write(x/10),putchar(x%10+'0');
}

map<int,ll> p;

int main() {
	#ifdef LOCAL
		freopen("input.in","r",stdin);
		freopen("output.out","w",stdout);
	#endif
	int n;
	ll C,ans=0ll;
	cin>>n>>C;
	for(int i=1;i<=n;i++) {
		int x,y,z;
		cin>>x>>y>>z;
		p[x-1]+=ll(z);
		p[y]-=ll(z);
	}
	ll cst=0ll,preday=0ll;
	for(map<int,ll>::iterator it=p.begin();it!=p.end();it++) {
		ll fee;
		if(cst>C) fee=C;
		else fee=cst;
		ans+=((*it).fi-preday)*fee;
		cst+=(*it).se;
		preday=(*it).fi;
	}
	cout<<ans<<endl;
	return 0;
}
