n, ww = list(map(int, input().split()))



wv = [list(map(int, input().split())) for i in range(n)]

wv.sort(key=lambda x:x[1])

dp = {0:0}

for w, v in wv:

    dp_next = dp.copy()

    for key in dp:

        dp_next[key+v] = min(dp[key]+ w, dp.get(key+v, float("inf")))

    dp = dp_next

for key in sorted(list(dp.keys()), reverse=True):

    if dp[key] <= ww:

        print(key)

        exit()
import numpy as np



n, ww = list(map(int, input().split()))



wv = [list(map(int, input().split())) for i in range(n)]



dp = np.full(n*10**3+1, np.inf)

dp[0] = 0



for w, v in wv:

    dp[v:] = np.minimum(dp[v:], dp[:-v]+w)



for i in range(n*10**3+1)[::-1]:

    if dp[i] <= ww:

        print(i)

        exit()
n, ww = list(map(int, input().split()))
wv = [list(map(int, input().split())) for i in range(n)]
wv.sort(key=lambda x: x[1])
dp = {0: 0}
for w, v in wv:
    dp_next = dp.copy()
    for key in dp:
        dp_next[key + v] = min(dp[key] + w, dp.get(key + v, float("inf")))
    dp = dp_next
for key in sorted(list(dp.keys()), reverse=True):
    if dp[key] <= ww:
        print(key)
        exit()

import numpy as np

n, ww = list(map(int, input().split()))
wv = [list(map(int, input().split())) for i in range(n)]
dp = np.full(n * 10**3 + 1, np.inf)
dp[0] = 0
for w, v in wv:
    dp[v:] = np.minimum(dp[v:], dp[:-v] + w)
for i in range(n * 10**3 + 1)[::-1]:
    if dp[i] <= ww:
        print(i)
        exit()

+import numpy as np + -wv.sort(key=lambda x: x[1]) -dp = {0: 0} +dp = np.full(n * 10**3 + 1, np.inf) +dp[0] = 0 -    dp_next = dp.copy() -    for key in dp: -        dp_next[key + v] = min(dp[key] + w, dp.get(key + v, float("inf"))) -    dp = dp_next -for key in sorted(list(dp.keys()), reverse=True): -    if dp[key] <= ww: -        print(key) +    dp[v:] = np.minimum(dp[v:], dp[:-v] + w) +for i in range(n * 10**3 + 1)[::-1]: +    if dp[i] <= ww: +        print(i)