#include #include using namespace std; int main() { int N, W; cin >> N >> W; vector v(N), w(N); for (int i = 0; i < N; i++) { cin >> v[i] >> w[i]; } const int INF = 1e9 + 7; const int MAX_V = 1000 * 1000 + 5; vector dp(MAX_V, INF); dp[0] = 0; for (int i = 0; i < N; i++) { for (int j = MAX_V - 1; j >= v[i]; j--) { dp[j] = min(dp[j], dp[j - v[i]] + w[i]); } } int ans = -1; for (int i = MAX_V - 1; i >= 0; i--) { if (dp[i] <= W) { ans = i; break; } } cout << ans << endl; return 0; }