#include <bits/stdc++.h>

using namespace std;
using ll = long long int;
constexpr ll M = 1e9 + 7;
inline ll sum_1(const ll n) { return ((n * (n + 1)) / 2) % M; }
inline ll sum_2(const ll n) { return ((n * (n + 1) * (2 * n + 1)) / 6) % M; }
inline ll sum_3(const ll n) { return (((n * (n + 1)) / 2) % M * ((n * (n + 1)) / 2) % M) % M; }
inline ll sum_1(const ll i, const ll j) { return (sum_1(j) - sum_1(i - 1) + M) % M; }
inline ll sum_2(const ll i, const ll j) { return (sum_2(j) - sum_2(i - 1) + M) % M; }
inline ll sum_3(const ll i, const ll j) { return (sum_3(j) - sum_3(i - 1) + M) % M; }

/* clang-format off */
namespace myDebug {
template <class T> auto is_printable(T *v) -> decltype(cout << *v, 0);
template <class T> char is_printable(...);
template <class T> struct range{T begin, end;};

class Debug {
    class DebugImpl {
      public:
        ~DebugImpl() { cout << endl; }
        #define enable_cond(cmp) enable_if<sizeof(is_printable<T>(nullptr)) cmp 1, DebugImpl &>::type
        template <class T> typename enable_cond(!=) operator<<(const T v) {
            cout << v; return *this;
        }
        template <class T> typename enable_cond(==) operator<<(const T v) {
            return *this << range<decltype(begin(v))>({begin(v), end(v)});
        }
        template <class T, class U> DebugImpl& operator<<(const pair<T, U> p) {
            return *this << "(" << p.first << ", " << p.second << ")";
        }
        template <class T> DebugImpl& operator<<(const range<T> v) {
            for (auto it = v.begin; it != v.end; ++it) {
                *this << *it << " ";
            }
            return *this << "\n";
        }
        #ifdef enable_cond
        #undef enable_cond
        #endif
    } os;
  public:
    #ifdef D_LOCAL
    template<class T> Debug& operator<<(const T v) {
        os << v; cout << endl; return *this;
    }
    #else
    template <class T> Debug& operator<<(const T &) { return *this; }
    #endif
};
#define px(...) #__VA_ARGS__":" << (__VA_ARGS__)
}; // namespace myDebug
/* clang-format on */
myDebug::Debug debug;

ll pow_f(ll b, ll e, ll M = ::M) {
    ll ans = 1;
    b = b % M;
    while (e) {
        if (e & 1) {
            ans = (ans * b) % M;
        }
        b = (b * b) % M;
        e >>= 1;
    }
    return ans;
}

ll nCr(ll n, ll r) {
    if (r > n || n < 0 || r < 0) { return 0; }
    if (n == r || r == 0) { return 1; }
    r = min(r, n - r);
    ll ans = 1;
    for (ll i = 1; i <= r; ++i) {
        ans = (ans * (n - i + 1)) / (i);
    }
    return ans;
}

ll nCr(tuple<ll, ll> t) {
    auto n = get<0>(t);
    auto k = get<1>(t);
    return nCr(n + k - 1, k);
}

ll modinv(ll x, ll M = ::M) {
    return pow_f(x, M - 2, M);
}

void solve() {
    ll n, w;
    cin >> n >> w;
    vector<pair<ll,ll>> obj(n);
    ll v = 0;
    for (auto &i : obj) {
        cin >> i.first >> i.second; // <w, v>
        v += i.second;
    }

    /**
     * 1 2 3 4 ... N
     *     choose / reject ---> change wt, change value
     * 
     * dp[i][v] = considering [1...i] i'th obj, total value v with min with
     * 
     * dp[i][v] = min{dp[i-1][v], w'+dp[i-1][v-v']}
     * 
     */
    vector<vector<ll>> dp(n+1, vector<ll>(v+1,-1));
    for (int i = 0; i <= n; ++i)
        dp[i][0] = -1;
    for (int i = 0; i <= v; ++i)
        dp[0][i] = -1;  
    
    dp[0][0] = 0;

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= v; ++j) {
            dp[i][j] = -1;
            if (obj[i-1].second == j)
                dp[i][j] = obj[i-1].first;
            if (dp[i-1][j] != -1)
                if (dp[i][j] == -1)
                    dp[i][j] = dp[i-1][j];
                else
                    dp[i][j] = min(dp[i][j], dp[i-1][j]);
            if (j-obj[i-1].second >= 0 && dp[i-1][j-obj[i-1].second] != -1)
                if (dp[i][j] != -1)
                    dp[i][j] = min(dp[i][j], obj[i-1].first + dp[i-1][j-obj[i-1].second]);
                else
                    dp[i][j] = obj[i-1].first + dp[i-1][j-obj[i-1].second];
        }
    }

    ll max_val = 0;
    for (int i = v; i >= 0; --i) {
        for (int j = 0; j <= n; ++j) {
            if (dp[j][i] != -1 && dp[j][i] <= w) {
                max_val = i;
                goto found;
            }
        }
    }
    found:
    // debug << dp;
    cout << max_val << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef D_LOCAL
        freopen("in.in", "r", stdin);
        freopen("out.out", "w", stdout);
    #endif

    solve();

    return 0;
}

Measured memory_bytes: 80256