#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;

const int INF = 2e9;

int main(){
    ll n,x;
    cin >> n >> x;
    vector<pair<ll,ll>> events;
    rep(i,n){
        ll a,b,c;
        cin >> a >> b >> c;
        events.emplace_back(a,c);
        events.emplace_back(b+1,-c);
    }
    sort(events.begin(),events.end());
    ll ans = 0,s = 0,pre = 0;
    for(auto event : events){
        ans += min(x,s)*(event.first - pre);
        s += event.second;
        pre = event.first;
    }
    cout << ans << endl;
}
#include<bits/stdc++.h>
#define con(typ) const typ
typedef long long ll;
template<typename T>void sf(T &x){x=0;T f=0;char c=getchar();for(;c<'0'||c>'9';c=getchar())if(c=='-')f=1;for(;c>='0'&&c<='9';c=getchar())x=(x<<3)+(x<<1)+(c^'0');if(f)x=-x;}
template<typename T>void pf(T x,char l='\n'){static int s[100],t;if(x<0)putchar('-'),x=-x;do s[++t]=x%10,x/=10;while(x);while(t)putchar(s[t--]^'0');putchar(l);}
int main()
{
	int a,b,c;
	sf(a),sf(b),sf(c);
	pf(3*7-a-b-c); 
	return 0;
}