#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long int ll;
#define MOD 1000000007
#define INF 1e18
#include <ctime>
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define rev(i, n, x) for (ll i = n; i > x; i--)
#define endl "\n"
#define all(c) (c).begin(), (c).end()
#define int long long int
#ifdef mishra
#define debug(x) cout << " >> " << #x << ": " << x;
#define print_time() cout << setprecision(6) << "time: " << (clock() - start) / (double)CLOCKS_PER_SEC << '\n';
#else
#define debug(x) ;
#define print_time() ;
#endif

clock_t start;
void FAST(ll argc)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    start = clock();
    if (argc == 2)
        freopen("std.in", "r", stdin);
}

/*vector<ll> v;
void seive()
{
    v.pb(2);
    for (int i = 3; i < 100000; i += 2)
    {
        for (int j = 0; j < v.size(); j++)
        {
            if (i % v[j] == 0)
                break;
            if (v[j] * v[j] > i)
            {
                v.pb(i);
                break;
            }
        }
    }
}
/*
void prime_factor(ll x, vector<ll> &r)
{
    ll sqrt_x = sqrt(x);

    for (ll i : v)
    {
        if (i > sqrt_x)
            break;

        if (x % i == 0)
            r.pb(i);

        while (x % i == 0)
        {
            x /= i;
        }
    }

    if (x >= 2)
        r.pb(x);
}
*/
/*
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % MOD;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % MOD;
        y = y >> 1;
        x = (x * x) % MOD;
    }
    return res;
}
*/
/*
inline void dfs(ll curr, ll prev)
{

    for (ll i : a[curr])
        if (i != prev)
            dfs(i, curr);
}
*/
/*
ll multi(ll a, ll b)
{
    return ((a * b) % MOD);
}
*/
//---------------------CODE STARTS HERE---------------------
int mini(int x, int y)
{
    if (x * y == 0)
        return x + y;
    else
        return (min(x, y));
}

signed main(char argc, char *argv[])
{
    FAST(argc);

    ll testcase = 1;
    //cin >> testcase;

    while (testcase--)
    {
        int n, w;
        cin >> n >> w;
        pair<int, int> p[n];
        rep(i, 0, n)
        {
            int x, y;
            cin >> x >> y;
            p[i] = make_pair(y, x);
        }
        sort(p, p + n);
        map<int, int> v;
        for (auto i : p)
        {
            stack<pair<int, int>> s;
            for (auto j : v)
            {
                s.push(make_pair(j.first + i.first, mini(v[j.first + i.first], j.second + i.second)));
                if(v[j.first + i.first]==0)
                    v.erase(j.first + i.first);
                
            }
            s.push(make_pair(i.first, mini(v[i.first], i.second)));
            while (s.empty() == 0)
            {
                auto j = s.top();
                v[j.first] = j.second;
                s.pop();
            }
        }
        int ans = 0;
        for (auto i = v.rbegin(); i != v.rend(); i++)
        {
            if ((*i).second <= w)
            {
                ans = ((*i).first);
                break;
            }
        }
        // debug(ans);
        cout << ans << endl;

        //--------??--------CLEAR VECTORS--------??--------
    }

    //v.clear();
    print_time();
    return 0;
}

Measured memory_bytes: 4480