#include #include using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 5000000000000000000 int main(){ int N,B; cin>>N>>B; vector x(N),y(N),p(N); vector t; vector ind; rep(i,N){ cin>>x[i]>>y[i]>>p[i]; t.push_back(x[i]); ind.push_back(i); } sort(ind.begin(),ind.end(),[&](int a,int b){ return y[a]> temp; rep(k,N){ if(x[ind[k]]>=t[i]&&x[ind[k]]<=t[j]){ temp.emplace_back(y[ind[k]],p[ind[k]]); } } int s = 0,l = 0; rep(k,temp.size()){ s += temp[k].second; if(k!=temp.size()-1 && temp[k+1].first==temp[k].first)continue; while(true){ if(s<=B){ if(l==0 || temp[l].first!=temp[l-1].first)break; } s -= temp[l].second; l++; } ans = max(ans,k-l+1); } } } cout<