#include<bits/stdc++.h>
 
#define repa(x,y,z) for(ll x=y;x<z;x++)
#define ll long long int
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define memf(a) memset(a,false,sizeof(a))
#define F first
#define S second
#define ot(a) cout<<a<<endl;
#define endl "\n"
#define godspeed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vl vector<long long int>
#define pi 3.141592653589793238
 
using namespace std;
int M=1e9+7;
ll INF=1e18+7;
 
/**************************************************************************************************/
ll power( ll b, ll e)
{
    if (e == 0) return 1;
    if (e & 1) return b * power(b * b, e / 2);
    return power(b * b, e / 2);
}

ll powmod(ll a, ll b) {
    if (b == 0)
        return 1;
    ll res = powmod(a, b / 2)%M;
    if (b % 2)
        return ((((ll)res * (ll)res) %M)* (ll)a)%M;
    else
        return ((ll)res * (ll)res)%M;
}
 
//use like
//vector< pair<int, int> >v;
//sort(v.begin(),v.end(),compare);
bool compare(const pair<ll, ll>&i, const pair<ll, ll>&j)
{
    return i.first < j.first;
}

bool comp(const pair<int, pair<int,int> >&i, const pair<int, pair<int,int> >&j)
{
    if(i.S.F==j.S.F)
        return i.S.S>j.S.S;
    return i.S.F < j.S.F;
}

vector<int> prime;

void seive(int n)
{
    bitset<200005> vis;
    repa(i,2,n)
    {
        if(vis[i]==1)
            continue;
        prime.pb(i);
        for(int j=i;j*i<=n;j++)
        {
            vis[j*i]=1;
        }
    }
}
 
/*******************

1. to_string() -> int to string
2. stoi() -> string to int

*******************/

/**************************************************************************************************/


void Piyush_Orz(){
    ll n,c1; cin>>n>>c1;

    ll a,b,c;
    pair<ll,ll> p1[n],p2[n];
    set<ll> s;

    repa(i,0,n) 
    {
        cin>>a>>b>>c;
        s.insert(a);
        s.insert(b);
        p1[i]=mp(a,c);
        p2[i]=mp(b,c);
    }

    sort(p1,p1+n);
    sort(p2,p2+n);

    ll i=0,k1=0,k2=0;
    vector<ll> v[s.size()];
    for(auto x:s)
    {
        while(p1[k1].F==x)
            v[i].pb(p1[k1].S),k1++;

        while(p2[k2].F==x)
            v[i].pb(-1*p2[k2].S),k2++; 

        i++;       
    }

    i=0;
    ll m=0,last=-1;
    ll ans=0;
    for(auto x:s)
    {
        if(last>0)
        {
            if(m<c1)
                ans+=((ll)(x-last-1))*m;
            else
                ans+=((ll)(x-last-1))*c1;
        }

        for(auto y:v[i])
        {
            if(y>0)
                m+=y;
        }
        if(m<c1)
            ans+=m;
        else
            ans+=c1;

        for(auto y:v[i])
        {
            if(y<0)
                m+=y;
        }

        last=x;
        i++;
    }

    cout<<ans;

} 


int main()
{
 
 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    
    godspeed
    
    seive(30005);
    #ifdef NCR
        init();
    #endif
    
    ll t = 1;
    //cin >> t;
    cout << fixed << setprecision(12);
    
    repa(i, 0, t)
    {
        Piyush_Orz();
    }
}





        
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define P pair<ll, ll>

int main(){
    ll N;
    cin >> N;
    double x_0, y_0;
    double x_half, y_half;
    cin >> x_0 >> y_0;
    cin >> x_half >> y_half;

    double x_center = (x_0 + x_half)/2.0;
    double y_center = (y_0 + y_half)/2.0;

    double x_1 = (x_0 - x_center) * cos(2 / (double)N * M_PI) - (y_0 - y_center) * sin(2 / (double)N * M_PI) + x_center;
    double y_1 = (x_0 - x_center) * sin(2 / (double)N * M_PI) + (y_0 - y_center) * cos(2 / (double)N * M_PI) + y_center;

    cout << x_1 << " " << y_1 << endl;
}