import sys

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)



import numpy as np



N,W = list(map(int,input().split()))



# v に対する min(w) を持つ

max_v = 0

INF = 10 ** 18

dp = np.full(1000 * N + 1, INF, dtype=np.int64)

dp[0] = 0

for _ in range(N):

    w,v = list(map(int,input().split()))

    np.minimum(dp[v:max_v + v + 1], dp[:max_v + 1]+w, out = dp[v:max_v + v + 1])

    max_v += v



answer = np.where(dp <= W)[0].max()

print(answer)
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



import numpy as np



N,W = list(map(int,readline().split()))

m = list(map(int,read().split()))

WV = list(zip(m,m))



# 価値 -> 最小重さ

INF = 10**18

dp = np.full(10**5+10,INF,np.int64)



dp[0] = 0

for w,v in WV:

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



answer = np.where(dp<=W)[0][-1]

print(answer)
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
import numpy as np

N, W = list(map(int, input().split()))
# v に対する min(w) を持つ
max_v = 0
INF = 10**18
dp = np.full(1000 * N + 1, INF, dtype=np.int64)
dp[0] = 0
for _ in range(N):
    w, v = list(map(int, input().split()))
    np.minimum(dp[v : max_v + v + 1], dp[: max_v + 1] + w, out=dp[v : max_v + v + 1])
    max_v += v
answer = np.where(dp <= W)[0].max()
print(answer)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

N, W = list(map(int, readline().split()))
m = list(map(int, read().split()))
WV = list(zip(m, m))
# 価値 -> 最小重さ
INF = 10**18
dp = np.full(10**5 + 10, INF, np.int64)
dp[0] = 0
for w, v in WV:
    np.minimum(dp[v:], dp[:-v].copy() + w, out=dp[v:])
answer = np.where(dp <= W)[0][-1]
print(answer)

-input = sys.stdin.readline -sys.setrecursionlimit(10**7) +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines -N, W = list(map(int, input().split())) -# v に対する min(w) を持つ -max_v = 0 +N, W = list(map(int, readline().split())) +m = list(map(int, read().split())) +WV = list(zip(m, m)) +# 価値 -> 最小重さ -dp = np.full(1000 * N + 1, INF, dtype=np.int64) +dp = np.full(10**5 + 10, INF, np.int64) -for _ in range(N): -    w, v = list(map(int, input().split())) -    np.minimum(dp[v : max_v + v + 1], dp[: max_v + 1] + w, out=dp[v : max_v + v + 1]) -    max_v += v -answer = np.where(dp <= W)[0].max() +for w, v in WV: +    np.minimum(dp[v:], dp[:-v].copy() + w, out=dp[v:]) +answer = np.where(dp <= W)[0][-1]