#include <bits/stdc++.h>                                                                                                                                
using namespace std;                                                                                                                                    
                                                                                                                                                        
int main(){                                                                                                                                             
    int n, W; cin >> n >> W;                                                                                                                            
        vector<long long> v(n+1), w(n+1);                                                                                                               
                                                                                                                                                        
    for (int i=1; i<=n; i++){                                                                                                                           
        cin >> w[i];                                                                                                                                    
        cin >> v[i];                                                                                                                                    
    }                                                                                                                                                   
                                                                                                                                                        
    vector<vector<long long>> dp(101, vector<long long>(1e5+1, 1e12));                                                                                  
                                                                                                                                                        
    for (int i=1; i<=n; i++){                                                                                                                           
        for (int j=1; j<=1e5; j++){                                                                                                                     
            if (v[i] < j) dp[i][j] = min(dp[i-1][j], w[i] + dp[i-1][j-v[i]]);                                                                           
            else dp[i][j] = min(w[i], dp[i-1][j]);                                                                                                      
        }                                                                                                                                               
    }                                                                                                                                                   
                                                                                                                                                        
    for (int j=1e5; j>=0; j--){                                                                                                                         
        for (int i=0; i<=n; i++){                                                                                                                       
            if (dp[i][j]<=W) {                                                                                                                          
                cout << j << endl;                                                                                                                      
                goto out;                                                                                                                               
            }                                                                                                                                           
        }                                                                                                                                               
    }                                                                                                                                                   
                                                                                                                                                        
out:                                                                                                                                                    
                                                                                                                                                        
    return 0;                                                                                                                                           
}        

Measured memory_bytes: 83200