#include using namespace std; signed main(){ int n,l;cin>>n>>l; int nowt=0,nowp=0; while(n--){ int x,w,t;cin>>x>>w>>t; nowt+=x-nowp; int A=nowt%(2*t); if(t-A>=w)nowt+=w; else nowt+=2*t-A+w; nowp=x+w; } nowt+=l-nowp; cout<