#include using namespace std; #define int long long const int maxn = 1005; int dp[maxn]; int w[maxn],c[maxn]; signed main(){ int n,m; cin >> n >> m; for(int i = 0;i> w[i] >> c[i]; } for(int i = 0;i= c[i];--j){ dp[j] = max(dp[j],dp[j-w[i]] + c[i]); } } cout << dp[m]; return 0; }