#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
/*
    vec1.size();
    str1.length();
    vec1.pop_back;
*/
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<pll> vplll;
#define rep(i,l,r) for (ll i = l; i < r; ++i)
#define reprev(i,l,r) for (ll i = r; i >= l; --i)
ll mod = 1e9+7;
ll expo_mod(ll x, ll y, ll p) 
{ 
    ll res = 1;
    x = x % p; 
    if (x == 0) 
        return 0; 
    while (y > 0) 
    {
        if (y%2==1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,w,sum,sum_w=0;
    cin>>n>>w;
    ll weight[n+1],value[n+1];
    sum=0;
    rep(i,1,n+1)
    {
        cin>>weight[i]>>value[i];
        sum+=value[i];
        sum_w+=weight[i];
    }
    ll dp[n+1][sum+1];
    ll val1,val2,ans;
    // cout<<"ne"<<endl;
    rep(i,0,n+1)
    {
        reprev(j,0,sum)
        {
            if(i==0)
            {
                if(j==0)
                {
                    dp[i][j]=0;
                }
                else
                {
                    dp[i][j]=-1;
                }
            }
            else
            {
                // if(j!=sum)
                {
                    val1=dp[i-1][j];
                }
                // else
                // {
                //     if(i==n)
                //     {
                //         cout<<"wow\n";
                //         val1=sum_w;
                //     }
                //     else
                //     {
                    
                //         val1=-1;
                //     }
                // }
                
                if(j-value[i]<=0)
                {
                    val2=weight[i];
                }
                else
                {
                    if(dp[i-1][j-value[i]]==-1)
                    {
                        val2=-1;
                    }
                    else
                    {
                        val2=weight[i]+dp[i-1][j-value[i]];
                    }
                }
                if(val1==-1 && val2==-1)
                {
                    dp[i][j]=-1;
                }
                else if(val1==-1 || val2==-1)
                {
                    dp[i][j]=max(val1,val2);
                }
                else
                {
                    dp[i][j]=min(val1,val2);
                }
                
            }
            
        }
    }
    ans=0;
    reprev(j,0,sum)
    {
        if(dp[n][j]!=-1 && dp[n][j]<=w)
        {
            ans=j;
            break;
        }
    }
    // rep(i,0,n+1)
    // {
    //     rep(j,0,sum+1)
    //     {
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<"\n";
    // }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 79104