#include using namespace std; #define REP(i,a,b) for(int i=a;i<(int)b;i++) #define rep(i,n) REP(i,0,n) #define chmax(a,x) a = max(a, x) typedef long long ll; ll N, B; typedef pair pdd; typedef pair pd3; pd3 p[444]; int main() { cin >> N >> B; rep(i, N) { double x, y, sc; cin >> x >> y >> sc; p[i] = {{x, y}, sc}; } sort(p, p+N); ll ans = 0; rep(i, N) REP(j, i+1, N) { int L = i, R = i; ll sum = 0; while(L <= j && R <= j) { if(sum + p[R].second <= B) { sum += p[R++].second; chmax(ans, (ll)(R-L)); } else { sum -= p[L++].second; if(sum < 0) { R = L; sum = 0; } } } } cout << ans << endl; return 0; }