import numpy as np

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

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



INF = 10**9 + 100

MAX_V = 10 ** 6



dp = np.full((n+1, MAX_V), INF, np.int64)

dp[0][0] = 0



for i, (wi, vi) in enumerate(wv):

    dp[i+1] = dp[i]

    np.minimum(dp[i][vi:], dp[i][:-vi] + wi, out=dp[i+1][vi:])



ans = np.where(dp[n] <= w)[0][-1]

print(ans)

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

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



INF = 10**9 + 100

MAX_V = 10**5 + 100

dp = [INF] * (MAX_V + 1)

dp[0] = 0



for wi, vi in wv:

    for sum_v in range(MAX_V, vi-1, -1):

        dp[sum_v] = min(dp[sum_v - vi] + wi, dp[sum_v])

#print(dp)

ans = 0

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

    if dp[i] <= w:

        print(i)

        exit()

#print(ans)

import numpy as np

n, w = list(map(int, input().split()))
wv = [tuple(map(int, input().split())) for _ in range(n)]
INF = 10**9 + 100
MAX_V = 10**6
dp = np.full((n + 1, MAX_V), INF, np.int64)
dp[0][0] = 0
for i, (wi, vi) in enumerate(wv):
    dp[i + 1] = dp[i]
    np.minimum(dp[i][vi:], dp[i][:-vi] + wi, out=dp[i + 1][vi:])
ans = np.where(dp[n] <= w)[0][-1]
print(ans)

n, w = list(map(int, input().split()))
wv = [tuple(map(int, input().split())) for _ in range(n)]
INF = 10**9 + 100
MAX_V = 10**5 + 100
dp = [INF] * (MAX_V + 1)
dp[0] = 0
for wi, vi in wv:
    for sum_v in range(MAX_V, vi - 1, -1):
        dp[sum_v] = min(dp[sum_v - vi] + wi, dp[sum_v])
# print(dp)
ans = 0
for i in range(MAX_V, -1, -1):
    if dp[i] <= w:
        print(i)
        exit()
# print(ans)

-import numpy as np - -MAX_V = 10**6 -dp = np.full((n + 1, MAX_V), INF, np.int64) -dp[0][0] = 0 -for i, (wi, vi) in enumerate(wv): -    dp[i + 1] = dp[i] -    np.minimum(dp[i][vi:], dp[i][:-vi] + wi, out=dp[i + 1][vi:]) -ans = np.where(dp[n] <= w)[0][-1] -print(ans) +MAX_V = 10**5 + 100 +dp = [INF] * (MAX_V + 1) +dp[0] = 0 +for wi, vi in wv: +    for sum_v in range(MAX_V, vi - 1, -1): +        dp[sum_v] = min(dp[sum_v - vi] + wi, dp[sum_v]) +# print(dp) +ans = 0 +for i in range(MAX_V, -1, -1): +    if dp[i] <= w: +        print(i) +        exit() +# print(ans)