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()

inf = float('inf')



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

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

wt, vt = list(zip(*e))

sv = sum(vt)



dp = tuple([inf] * (sv + 1) for _ in range(n + 1))

dp[0][0] = 0



for i in range(n):

    dp[i + 1][:vt[i]] = dp[i][:vt[i]]

    for j in range(vt[i], sv + 1):

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



res = -1

for j in range(sv, -1, -1):

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

        res = j

        break

print(res)

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()

inf = float("inf")
n, w = list(map(int, input().split()))
e = tuple(list(map(int, input().split())) for _ in range(n))
wt, vt = list(zip(*e))
sv = sum(vt)
dp = tuple([inf] * (sv + 1) for _ in range(n + 1))
dp[0][0] = 0
for i in range(n):
    dp[i + 1][: vt[i]] = dp[i][: vt[i]]
    for j in range(vt[i], sv + 1):
        dp[i + 1][j] = min(dp[i][j], dp[i][j - vt[i]] + wt[i])
res = -1
for j in range(sv, -1, -1):
    if dp[n][j] <= w:
        res = j
        break
print(res)

-wv = tuple(tuple(map(int, input().split())) for _ in range(n)) -dp = tuple([inf] * (pow(10, 3) * n + 1) for _ in range(n + 1)) +e = tuple(list(map(int, input().split())) for _ in range(n)) +wt, vt = list(zip(*e)) +sv = sum(vt) +dp = tuple([inf] * (sv + 1) for _ in range(n + 1)) -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() +for i in range(n): +    dp[i + 1][: vt[i]] = dp[i][: vt[i]] +    for j in range(vt[i], sv + 1): +        dp[i + 1][j] = min(dp[i][j], dp[i][j - vt[i]] + wt[i]) +res = -1 +for j in range(sv, -1, -1): +    if dp[n][j] <= w: +        res = j +        break +print(res)