#include "bits/stdc++.h" #define REP(i,n,N) for(ll i=(n); i<(N); i++) #define RREP(i,n,N) for(ll i=(N-1); i>=n; i--) #define CK(n,a,b) ((a)<=(n)&&(n)<(b)) #define ALL(v) (v).begin(),(v).end() #define p(s) cout<<(s)<> typedef long long ll; using namespace std; const ll inf=1e18; ll N, L; int main(){ while(cin>>N>>L){ ll X[110] = {}; ll W[110] = {}; ll T[110] = {}; ll ans=0; X[0] = W[0] = T[0] = 0; REP(i,1,N+1){ cin>>X[i]>>W[i]>>T[i]; } REP(i,1,N+1){ ans+= X[i] - X[i-1]; ll x = ans%(2*T[i]); if(x + W[i] > T[i]){ ans += 2*T[i] - x; } } p(ans+=L-X[N]); } return 0; }