#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
#define Graph vector<vector<ll>>
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)
#define inf 1000000321
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main(){ 
    ll N,C;
    ll ans = 0;
    cin >> N;
    cin >> C;
    vector<ll> a(N),b(N),c(N);
    vector<pair<ll,ll>> kiroku;

    for(int i = 0;i < N;i++){
        cin >> a[i] >> b[i] >> c[i];
        kiroku.push_back(make_pair(a[i],c[i]));
        kiroku.push_back(make_pair(b[i]+1,-c[i]));
    }
    sort(all(kiroku));
    ll checked = -1;
    ll now = 0;
    for(int i = 0;i < kiroku.size();i++){
      if(checked !=-1 && now > C){
        ans += C * (kiroku[i].first - checked);
      }
      else if(checked != -1){
        ans += now * (kiroku[i].first -checked);
      }
      now += kiroku[i].second;
      checked = kiroku[i].first;
    }
    cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double dd;
#define tst int tttt;cin>>tttt;for(int TTTT=1;TTTT<=tttt;TTTT++)
#define nl cout<<"\n";
#define forn(a,b) for(int ii=a;ii<b;ii++)
const ll MOD1=1e9+7;
const ll MOD2=998244353;
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define vi vector<int>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define hhh cout<<"here"<<endl;

ll mod=MOD1;
ll po(ll x,ll y) {ll res=1;while(y>0){if(y&1)res=(res*x);x=(x*x);y>>=1;}return res;}
ll gcd(int a, int b){if(a<b) swap(a,b);if(b==0) return a;return gcd(a%b,b);}

void solve(){
    ll sx,sy,gx,gy;cin>>sx>>sy>>gx>>gy;
    double x=(sx*gy+gx*sy)*1.0/(sy+gy);
    cout<<setprecision(12)<<x;
}
int main(){
    // fastio
    // ++*(int*)0;// crash
    // freopen("out.txt","r",stdin);freopen("outt.txt","w",stdout);
    // preprocess();
    // tst
    {
        solve();nl;
    }
}
/*

u & (v-u//2)

sy*1.0/(x-sx) == gy/(gx-x)
*/
