import sys



input = sys.stdin.readline



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

w, v = [], []

for _ in range(N):

    tw, tv = list(map(int, input().split()))

    w.append(tw)

    v.append(tv)



dp = [[float('inf') for _ in range(sum(v) + 1)] for _ in range(N + 1)]

dp[0][0] = 0

# dp[何番目までの品物で][この価値以下を達成する]:=最小の重量



for i in range(N):

    for j in range(sum(v) + 1):

        if j - v[i] >= 0:

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

        else:

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



for j in sorted(list(range(sum(v) + 1)), reverse=True):

    t = dp[N][j]

    if t <= W:

        print(j)

        break

inf = float('inf')



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

wv = tuple(tuple(map(int, input().split())) for _ in range(n))



dp = tuple([inf] * (pow(10, 3) * n + 1) for _ in range(n + 1))

dp[0][0] = 0



for ind, (wi, vi) in enumerate(wv, 1):

    for v in range(pow(10, 3) * n + 1):

        if vi <= v:

            dp[ind][v] = min(dp[ind - 1][v], dp[ind - 1][v - vi] + wi)

        else:

            dp[ind][v] = dp[ind - 1][v]



for v in range(pow(10, 3) * n, 0, -1):

    if dp[n][v] <= w:

        print(v)

        exit()

import sys

input = sys.stdin.readline
N, W = list(map(int, input().split()))
w, v = [], []
for _ in range(N):
    tw, tv = list(map(int, input().split()))
    w.append(tw)
    v.append(tv)
dp = [[float("inf") for _ in range(sum(v) + 1)] for _ in range(N + 1)]
dp[0][0] = 0
# dp[何番目までの品物で][この価値以下を達成する]:=最小の重量
for i in range(N):
    for j in range(sum(v) + 1):
        if j - v[i] >= 0:
            dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i])
        else:
            dp[i + 1][j] = dp[i][j]
for j in sorted(list(range(sum(v) + 1)), reverse=True):
    t = dp[N][j]
    if t <= W:
        print(j)
        break

inf = float("inf")
n, w = list(map(int, input().split()))
wv = tuple(tuple(map(int, input().split())) for _ in range(n))
dp = tuple([inf] * (pow(10, 3) * n + 1) for _ in range(n + 1))
dp[0][0] = 0
for ind, (wi, vi) in enumerate(wv, 1):
    for v in range(pow(10, 3) * n + 1):
        if vi <= v:
            dp[ind][v] = min(dp[ind - 1][v], dp[ind - 1][v - vi] + wi)
        else:
            dp[ind][v] = dp[ind - 1][v]
for v in range(pow(10, 3) * n, 0, -1):
    if dp[n][v] <= w:
        print(v)
        exit()

-import sys - -input = sys.stdin.readline -N, W = list(map(int, input().split())) -w, v = [], [] -for _ in range(N): -    tw, tv = list(map(int, input().split())) -    w.append(tw) -    v.append(tv) -dp = [[float("inf") for _ in range(sum(v) + 1)] for _ in range(N + 1)] +inf = float("inf") +n, w = list(map(int, input().split())) +wv = tuple(tuple(map(int, input().split())) for _ in range(n)) +dp = tuple([inf] * (pow(10, 3) * n + 1) for _ in range(n + 1)) -# dp[何番目までの品物で][この価値以下を達成する]:=最小の重量 -for i in range(N): -    for j in range(sum(v) + 1): -        if j - v[i] >= 0: -            dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]) +for ind, (wi, vi) in enumerate(wv, 1): +    for v in range(pow(10, 3) * n + 1): +        if vi <= v: +            dp[ind][v] = min(dp[ind - 1][v], dp[ind - 1][v - vi] + wi) -            dp[i + 1][j] = dp[i][j] -for j in sorted(list(range(sum(v) + 1)), reverse=True): -    t = dp[N][j] -    if t <= W: -        print(j) -        break +            dp[ind][v] = dp[ind - 1][v] +for v in range(pow(10, 3) * n, 0, -1): +    if dp[n][v] <= w: +        print(v) +        exit()