import numpy as np



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

items = []

for _ in range(N):

    items.append(tuple(map(int, input().split())))

v_max = sum([i[1] for i in items])

INF = 10**12

dp = np.array([[INF for j in range(v_max+1)] for _ in range(N+1)])

dp[0, 0] = 0

for i in range(1, N+1):

    w, v = items[i-1]

    dp[i, :v] = dp[i-1, :v]

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

ans = 0

for v in range(v_max, -1, -1):

    if dp[N][v] <= W:

        ans = v

        break

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

items = []

INF = 10**12

for _ in range(N):

    items.append(tuple(map(int, input().split())))

MAX_V = sum([v for _, v in items])

dp = [[INF for j in range(MAX_V+1)] for i in range(N+1)]

dp[0][0] = 0

for i in range(1, N+1):

    w, v = items[i-1]

    for j in range(MAX_V+1):

        if j - v >= 0:

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

        else:

            dp[i][j] = dp[i-1][j]

for v in range(MAX_V, -1, -1):

    if dp[N][v] <= W:

        break

print(v)
import numpy as np

N, W = list(map(int, input().split()))
items = []
for _ in range(N):
    items.append(tuple(map(int, input().split())))
v_max = sum([i[1] for i in items])
INF = 10**12
dp = np.array([[INF for j in range(v_max + 1)] for _ in range(N + 1)])
dp[0, 0] = 0
for i in range(1, N + 1):
    w, v = items[i - 1]
    dp[i, :v] = dp[i - 1, :v]
    dp[i, v:] = np.minimum(dp[i - 1, :-v] + w, dp[i - 1, v:])
ans = 0
for v in range(v_max, -1, -1):
    if dp[N][v] <= W:
        ans = v
        break
print(ans)

N, W = list(map(int, input().split()))
items = []
INF = 10**12
for _ in range(N):
    items.append(tuple(map(int, input().split())))
MAX_V = sum([v for _, v in items])
dp = [[INF for j in range(MAX_V + 1)] for i in range(N + 1)]
dp[0][0] = 0
for i in range(1, N + 1):
    w, v = items[i - 1]
    for j in range(MAX_V + 1):
        if j - v >= 0:
            dp[i][j] = min(dp[i - 1][j - v] + w, dp[i - 1][j])
        else:
            dp[i][j] = dp[i - 1][j]
for v in range(MAX_V, -1, -1):
    if dp[N][v] <= W:
        break
print(v)

-import numpy as np - +INF = 10**12 -v_max = sum([i[1] for i in items]) -INF = 10**12 -dp = np.array([[INF for j in range(v_max + 1)] for _ in range(N + 1)]) -dp[0, 0] = 0 +MAX_V = sum([v for _, v in items]) +dp = [[INF for j in range(MAX_V + 1)] for i in range(N + 1)] +dp[0][0] = 0 -    dp[i, :v] = dp[i - 1, :v] -    dp[i, v:] = np.minimum(dp[i - 1, :-v] + w, dp[i - 1, v:]) -ans = 0 -for v in range(v_max, -1, -1): +    for j in range(MAX_V + 1): +        if j - v >= 0: +            dp[i][j] = min(dp[i - 1][j - v] + w, dp[i - 1][j]) +        else: +            dp[i][j] = dp[i - 1][j] +for v in range(MAX_V, -1, -1): -        ans = v -print(ans) +print(v)