#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
 
typedef long long int ll;
const ll N = 1e6 +9;
const ll p = 31;
const ll m = 1e9 + 7;
const ll inf= 1e14;
const ll mod = 1e9+7;
#define w first
#define v second
#define pb push_back
#define mp make_pair
using pii = pair<ll, ll>;

ll powm(ll a, ll b) { ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
ll val[N];
ll adj[N][2];
ll ans = 0;
multiset<ll> l,r;
map<ll,bool> cnbf;
map<ll,int> ct;
void dfs(ll v){
     if(adj[v][0]!=-1){
          l.insert(val[v]);
          dfs(adj[v][0]);
          auto e = l.find(val[v]);
          l.erase(e);
     }
     if(adj[v][1]!=-1){
          r.insert(val[v]);
          dfs(adj[v][1]);
          auto e = r.find(val[v]);
          r.erase(e);
     }
     ll ul = inf;
     ll ll = 0;
     if(l.size() ){
          ul = *l.begin();
         
     }
     if(r.size()){
          ll = *r.rbegin();
          // cout<<ll<<'\n';
     }
          // cout<<v<<" "<<ul<<" "<<ll<<'\n';

     if(val[v]>=ll && val[v]<=ul){
          cnbf[val[v]] = 1;
     }


}
int main() {   
     ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
     

     ll q = 1;
     // cin>>q;
     while(q--){
          ll n,W;cin>>n>>W;
          pii a[n];
          ll maxv = 0;
          for(int i = 0;i<n;i++){
               cin>>a[i].w>>a[i].v;
               maxv+=a[i].v;
          }
          ll dp[n][maxv+1];
          memset(dp,0,sizeof(dp));
          for(int i = 0;i<n;i++){
               if(i==0)dp[i][a[i].v]=a[i].w;
               else
               for(int v = 1;v<=maxv;v++){
                    if(v>a[i].v){
                         if(dp[i-1][v] && dp[i-1][v-a[i].v])
                              dp[i][v] = min(dp[i-1][v],dp[i-1][v-a[i].v]+a[i].w);
                         else if(dp[i-1][v])
                              dp[i][v] = dp[i-1][v];
                         else if(dp[i-1][v-a[i].v])
                              dp[i][v] = dp[i-1][v-a[i].v]+a[i].w;
                    }
                    else if(v<a[i].v){
                         // if(v==30){
                              // cout<<dp[i][v]<<'\n';
                         // }
                         dp[i][v] = dp[i-1][v];
                    }
                    else{
                         dp[i][v] = a[i].w;
                         if(dp[i-1][v]>0){
                              dp[i][v] = min(dp[i][v],dp[i-1][v]);
                         }
                    }


               }
          }
          // for(int i = 0;i<n;i++){
          //      for(int v = 1;v<=maxv;v++){
          //           cout<<dp[i][v]<<" ";
          //      }
          //      cout<<'\n';
          // }
          ll ans;
          for(int v = 0;v<=maxv;v++){
               if(dp[n-1][v]<=W && dp[n-1][v]>0)
                    ans=v;
          }
          cout<<ans<<'\n';
     }
}         

Measured memory_bytes: 78336