import sys

input = sys.stdin.readline



N, W = [int(x) for x in input().split()]

wv = []

for _ in range(N):

    wv.append([int(x) for x in input().split()])

V = 10 ** 5

inf = float("inf")



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

dp[0][0] = 0

ans = -1



for i in range(N):

    for j in range(V + 1):

        w, v = wv[i]

        if j >= v:

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

        else:

            dp[i + 1][j] = dp[i][j]

        if dp[i + 1][j] <= W:

            ans = max(ans, j)

print(ans)
import sys

input = sys.stdin.readline



n, W = [int(x) for x in input().split()]

wv = [[int(x) for x in input().split()] for _ in range(n)]



dp = [[float('inf')] * (10**5 + 1) for _ in range(n + 1)]

dp[0][0] = 0



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

    w, v = wv[i - 1]

    for j in range(10**5 + 1):

        if j - v >= 0:

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

        else:

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



ans = 0



for i in range(10**5 + 1):

    if dp[-1][i] <= W:

        ans = max(ans, i)



print(ans)
import sys

input = sys.stdin.readline
N, W = [int(x) for x in input().split()]
wv = []
for _ in range(N):
    wv.append([int(x) for x in input().split()])
V = 10**5
inf = float("inf")
dp = [[inf] * (V + 1) for _ in range(N + 1)]
dp[0][0] = 0
ans = -1
for i in range(N):
    for j in range(V + 1):
        w, v = wv[i]
        if j >= v:
            dp[i + 1][j] = min(dp[i][j], dp[i][j - v] + w)
        else:
            dp[i + 1][j] = dp[i][j]
        if dp[i + 1][j] <= W:
            ans = max(ans, j)
print(ans)

import sys

input = sys.stdin.readline
n, W = [int(x) for x in input().split()]
wv = [[int(x) for x in input().split()] for _ in range(n)]
dp = [[float("inf")] * (10**5 + 1) for _ in range(n + 1)]
dp[0][0] = 0
for i in range(1, n + 1):
    w, v = wv[i - 1]
    for j in range(10**5 + 1):
        if j - v >= 0:
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v] + w)
        else:
            dp[i][j] = dp[i - 1][j]
ans = 0
for i in range(10**5 + 1):
    if dp[-1][i] <= W:
        ans = max(ans, i)
print(ans)

-N, W = [int(x) for x in input().split()] -wv = [] -for _ in range(N): -    wv.append([int(x) for x in input().split()]) -V = 10**5 -inf = float("inf") -dp = [[inf] * (V + 1) for _ in range(N + 1)] +n, W = [int(x) for x in input().split()] +wv = [[int(x) for x in input().split()] for _ in range(n)] +dp = [[float("inf")] * (10**5 + 1) for _ in range(n + 1)] -ans = -1 -for i in range(N): -    for j in range(V + 1): -        w, v = wv[i] -        if j >= v: -            dp[i + 1][j] = min(dp[i][j], dp[i][j - v] + w) +for i in range(1, n + 1): +    w, v = wv[i - 1] +    for j in range(10**5 + 1): +        if j - v >= 0: +            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v] + w) -            dp[i + 1][j] = dp[i][j] -        if dp[i + 1][j] <= W: -            ans = max(ans, j) +            dp[i][j] = dp[i - 1][j] +ans = 0 +for i in range(10**5 + 1): +    if dp[-1][i] <= W: +        ans = max(ans, i)