#include #include #include #include #include using namespace std; int main() { int n, b; cin >> n >> b; vector x(n, 0), y(n, 0), p(n, 0); int ans = 0; for (int i = 0; i < n; i++) { cin >> x[i] >> y[i] >> p[i]; if (p[i] < b) { ans = 1; } } if (ans == 0) { cout << ans << endl; return 0; } auto xx = x; auto yy = y; sort(xx.begin(), xx.end()); sort(yy.begin(), yy.end()); int total; int n_point; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { for (int k = 0; k < n; k++) { for (int l = k + 1; l < n; l++) { total = 0; n_point = 0; for (int m = 0; m < n; m++) { if (xx[i] <= x[m] && x[m] <= xx[j] && yy[k] <= y[m] && y[m] <= yy[l]) { total += p[m]; n_point++; } } if (total <= b) { ans = max(ans, n_point); } }}}} cout << ans << endl; return 0; }