/**
 *    author:  Eccentric_9
 *    created: 12.05.2021 17:34:05      
**/
#include<bits/stdc++.h>
using namespace std;

/*-----<Defines>-----*/
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     vl              vector<long long>
#define     pll             pair<long long,long long>
#define     mll             map<long long,long long>
#define     sl              set<long long>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     flush           fflush(stdout)
#define     FOR(i,a,b)      for(int i=a;i<=b;i++)
#define     FORD(i,a,b)     for(int i=a;i>=b;i--)
#define     r(i,n)          FOR(i,0,n-1)
#define     w(x)            int t;cin>>t;while(t--)
#define     en              '\n'
#define     sp              <<" "<<

using ull=unsigned long long;
using ll=long long;
using ld=long double;
/*-----</Defines>-----*/

/*-----<Debugging Stuff>-----*/
string to_string(char s)
{   string res="'''";res[1]=s;return res; }

string to_string(string s)
{   return '"'+s+'"'; }

string to_string(const char* s)
{   return to_string((string)s); }

string to_string(bool b)
{   return (b?"true":"false"); }

template<typename A, typename B>
string to_string(pair<A, B> p)
{   return "("+to_string(p.F)+", "+to_string(p.S)+")"; }

template<typename A>
string to_string(A v)
{
    bool first=1; string res="{";
    for(const auto &x:v)
    {
        if(!first)  res+=", ";
        first=0;
        res+=to_string(x);
    }
    res+="}";
    return res;
}

void debug() { cout<<"\n"; }
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cout<<" "<<to_string(H);
    debug(T...);
}

#define show(...) cout << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
/*-----</Debugging Stuff>-----*/

/*-----<Mod Operations>-----*/
const int M=1e9+7;
inline int add(int a,int b,int p=M){ a=a+b; if(a>=p) a-=p; return a; }
inline int sub(int a,int b,int p=M){ a=a-b; if(a<0) a+=p; return a; }
inline int mul(int a,int b,int p=M){ a=(a*1ll*b)%p; return a; }
/*-----</Mod Operations>-----*/

/*-----<Constants>-----*/
const ld pi=acos(-1),eps=1e-9;
const ll inf=1e18;
const int N=1e4+5,K=255;
/*-----</Constants>-----*/

ll n, m, q, k, l, r, x, y, z;
const ll template_array_size = 1e6;
ll a[template_array_size];
ll b[template_array_size];
ll c[template_array_size];
string s, t;
ll ans = 0;


void solve()
{
    ll c;
    cin>>n>>c;
    mll m;
    r(i,n){
        ll a,b,cc;
        cin>>a>>b>>cc;
        m[a]+=cc;
        m[b+1]-=cc;
    }auto it=m.begin();
    ll val=it->S,r=it->F;
    it++;
    for(it;it!=m.end();it++){
        val+=it->S;
        it->S=val;
    }it=m.begin();
    val=it->second;
    ans=0;
    for(it;it!=m.end();it++){
        if(it==m.end()) break;
        ans+=(it->F-r)*(min(c,val));
        val=it->S;
        r=it->F;
    }cout<<ans;
}


int main()
{
  /*#ifndef nipun_mitra
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif*/

  fast();
  //w(x)
  solve();
}

#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<stack>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> L_L;
const ll INF=2e18;
const ll MOD=1e9+7;

template <typename T>
class Zip {
public:
  vector<T> d;
  bool flag;
  Zip() {
    flag = false;
  }
  void add(T x) {
    d.push_back(x);
    flag = true;
  }
  ll getNum(T x) { // T need to have operator < !!
    if (flag) {
      sort(d.begin(), d.end());
      d.erase(unique(d.begin(), d.end()), d.end());
      flag = false;
    }
    return lower_bound(d.begin(), d.end(), x) - d.begin();
  }
  ll size() {
    if (flag) {
      sort(d.begin(), d.end());
      d.erase(unique(d.begin(), d.end()), d.end());
      flag = false;
    }
    return (ll)d.size();
  }
};


ll N,C;
map<ll,ll> sum;
ll a[200010],b[200010],c[200010];
int main(){
    cin>>N>>C;
    Zip<ll> zp;
    for(ll i=0;i<N;i++){
        cin>>a[i]>>b[i]>>c[i];
        zp.add(a[i]);
        zp.add(a[i]-1);
        zp.add(b[i]);
        zp.add(b[i]+1);
    }
    for(ll i=0;i<N;i++){
        sum[a[i]]+=c[i];
        sum[b[i]+1]-=c[i];
    }
    ll ans=0;
    for(ll i=1;i<zp.size();i++){
        sum[zp.d[i]] += sum[zp.d[i-1]];
        ans+=min(C,sum[zp.d[i-1]])*(zp.d[i]-zp.d[i-1]);
    }
    cout<<ans<<endl;

    return 0;
}