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

w,v = [0]*N,[0]*N

for i in range(N):

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

V = sum(v)

dp = [[float("inf")]*(V+1) for _ in range(N+1)]

dp[0][0] = 0



for i in range(N):

    for j in range(V+1):

        if j-v[i] >= 0:

            dp[i+1][j] = dp[i][j-v[i]]+w[i]

        dp[i+1][j] = min(dp[i+1][j], dp[i][j])



for i,d in enumerate(dp[N]):

    if d <= W:

        ans = i



print(ans)

import numpy as np

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



dp = np.full(N*10**3+1, W+1, dtype = np.int64)

dp[0] = 0



for i in range(N):

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

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



for i in range(N*10**3+1):

    if dp[i] <= W:

        ans = i

print(ans)

N, W = list(map(int, input().split()))
w, v = [0] * N, [0] * N
for i in range(N):
    w[i], v[i] = list(map(int, input().split()))
V = sum(v)
dp = [[float("inf")] * (V + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
    for j in range(V + 1):
        if j - v[i] >= 0:
            dp[i + 1][j] = dp[i][j - v[i]] + w[i]
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
for i, d in enumerate(dp[N]):
    if d <= W:
        ans = i
print(ans)

import numpy as np

N, W = list(map(int, input().split()))
dp = np.full(N * 10**3 + 1, W + 1, dtype=np.int64)
dp[0] = 0
for i in range(N):
    w, v = list(map(int, input().split()))
    np.minimum(dp[:-v] + w, dp[v:], out=dp[v:])
for i in range(N * 10**3 + 1):
    if dp[i] <= W:
        ans = i
print(ans)

+import numpy as np + -w, v = [0] * N, [0] * N +dp = np.full(N * 10**3 + 1, W + 1, dtype=np.int64) +dp[0] = 0 -    w[i], v[i] = list(map(int, input().split())) -V = sum(v) -dp = [[float("inf")] * (V + 1) for _ in range(N + 1)] -dp[0][0] = 0 -for i in range(N): -    for j in range(V + 1): -        if j - v[i] >= 0: -            dp[i + 1][j] = dp[i][j - v[i]] + w[i] -        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]) -for i, d in enumerate(dp[N]): -    if d <= W: +    w, v = list(map(int, input().split())) +    np.minimum(dp[:-v] + w, dp[v:], out=dp[v:]) +for i in range(N * 10**3 + 1): +    if dp[i] <= W: