#include using namespace std; void fast_io() { ios::sync_with_stdio(false); std::cin.tie(nullptr); } int main() { fast_io(); int N, I; cin >> N >> I; vector s(N), a(N); for (int i = 0; i < N; i++) { cin >> s[i] >> a[i]; } vector> dp(N + 1, vector(I + 1, 0)); for (int i = 0; i < N; i++) { for (int j = 0; j <= I; j++) { if (j >= s[i]) { dp[i + 1][j] = max(dp[i][j], dp[i][j - s[i]] + a[i]); } else { dp[i + 1][j] = dp[i][j]; } } } cout << dp[N][I] << endl; }