Problem:
Score : 100 points

Problem Statement

There are N items, numbered 1, 2, \ldots, N.
For each i (1 \leq i \leq N), Item i has a weight of w_i and a value of v_i.

Taro has decided to choose some of the N items and carry them home in a knapsack.
The capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W.

Find the maximum possible sum of the values of items that Taro takes home.

Constraints

All values in input are integers.

1 \leq N \leq 100

1 \leq W \leq 10^9

1 \leq w_i \leq W

1 \leq v_i \leq 10^3

Input

Input is given from Standard Input in the following format:

N W
w_1 v_1
w_2 v_2
:
w_N v_N

Output

Print the maximum possible sum of the values of items that Taro takes home.

Sample Input 1

3 8
3 30
4 50
5 60

Sample Output 1

90

Items 1 and 3 should be taken.
Then, the sum of the weights is 3 + 5 = 8, and the sum of the values is 30 + 60 = 90.

Sample Input 2

1 1000000000
1000000000 10

Sample Output 2

10

Sample Input 3

6 15
6 5
5 6
6 4
6 6
3 5
7 2

Sample Output 3

17

Items 2, 4 and 5 should be taken.
Then, the sum of the weights is 5 + 6 + 3 = 14, and the sum of the values is 6 + 6 + 5 = 17.

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

/*ANKON GHOSH
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e10
#define MAX 100005
#define mod 998244353
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) printf("Case %lld:\n",i)
#define pf(a) printf("%lld ",a)
#define pfsn printf("NO\n")
#define pfs  printf("YES\n")
#define pff(a,b) printf("%lld %lld\n",a,b)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll r=x;r<=y;r++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p(a,b) make_pair(a,b)
#define p_b(a) push_back(a)
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
map<ll,ll>mp,mp1;
vector<pair<ll,pair<ll,pair<ll,ll> > > >vpp,vpp1;
vector<pair<ll,ll> >vp,fin;
vector<ll>v,v1,v2,dummy;
map<pair<ll,ll>,ll>mpp;
///map<ll,bool>mb;
ll n,x,k,a,b,c,d,ta,sum=0,cnt=0,m,l,req,sz,w;
bool sortbysec(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{
    return (a.second < b.second);
}
struct data
{
    ll weight,value;
} arr[MAX];
ll dp[110][MAX+4];
ll ok;
ll calc(ll pos,ll nisi)
{
    if(pos>n)
    {
        if(nisi==0)
            return 0;
        else
            return inf;
    }
    else if(dp[pos][nisi]!=-1)
        return dp[pos][nisi];
    ll ret=0;
    if(pos==1 or nisi==ok)
    {
        if(nisi-arr[pos].value>=0)
            ret+=min(arr[pos].weight+calc(pos+1,nisi-arr[pos].value),calc(pos+1,nisi));
        else
            ret+=calc(pos+1,nisi);
    }
    else
    {
        if(nisi-arr[pos].value>=0)
            ret=min(ret,min(ret+arr[pos].weight+calc(pos+1,nisi-arr[pos].value),ret+calc(pos+1,nisi)));
        else
            ret=min(ret,ret+calc(pos+1,nisi));
    }
    return dp[pos][nisi]=ret;
}
int main()
{
    fast;
    cin>>n>>w;
    v.clear();
    memset(arr,0,sizeof arr);
    ll sum=0,tot=0;
    FOR1(i,n)
    {
        cin>>arr[i].weight>>arr[i].value;
    }
    memset(dp,-1,sizeof dp);
    FOR1(i,100000LL)
    {
        if(dp[1][i]==-1)
        {
            ok=i;
            ll x=calc(1,i);
            ///if(i<=20)
            ///cout<<dp[1][i]<<" ";
        }
        ///cout<<x<<" ";
    }
        ///cout<<endl;
    ll ans=0;
    FOR1(i,100000LL)
    {
        if(dp[1][i]<=w and dp[1][i]!=-1)
            ans=i;
    }
    cout<<ans<<endl;
    return 0;
}