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

weights, values = list(zip(*[tuple(map(int, input().split())) for _ in range(n)]))

UV = 10**5

INF = float('inf')

dp = [[0]+[INF]*UV for _ in range(n+1)]



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

    for j in range(1, UV+1):

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

        if 0 <= j-values[i-1]:

            dp[i][j] = min(dp[i][j], dp[i-1][j-values[i-1]]+weights[i-1])



ans = 0

for i in range(UV+1):

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

        ans = max(ans, i)

print(ans)

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

weights, values = list(zip(*[tuple(map(int, input().split())) for _ in range(n)]))

UV = 10**5

INF = 10**10

dp = [[INF]*(UV+1) for _ in range(n+1)]

for i in range(n+1):

    dp[i][0] = 0

    

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

    for j in range(1, UV+1):

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

        if 0 <= j-values[i-1]:

            dp[i][j] = min(dp[i][j], dp[i-1][j-values[i-1]]+weights[i-1])



ans = 0

for i in reversed(list(range(UV+1))):

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

        ans = i

        break

print(ans)
n, w = list(map(int, input().split()))
weights, values = list(zip(*[tuple(map(int, input().split())) for _ in range(n)]))
UV = 10**5
INF = float("inf")
dp = [[0] + [INF] * UV for _ in range(n + 1)]
for i in range(1, n + 1):
    for j in range(1, UV + 1):
        dp[i][j] = dp[i - 1][j]
        if 0 <= j - values[i - 1]:
            dp[i][j] = min(dp[i][j], dp[i - 1][j - values[i - 1]] + weights[i - 1])
ans = 0
for i in range(UV + 1):
    if dp[-1][i] <= w:
        ans = max(ans, i)
print(ans)

n, w = list(map(int, input().split()))
weights, values = list(zip(*[tuple(map(int, input().split())) for _ in range(n)]))
UV = 10**5
INF = 10**10
dp = [[INF] * (UV + 1) for _ in range(n + 1)]
for i in range(n + 1):
    dp[i][0] = 0
for i in range(1, n + 1):
    for j in range(1, UV + 1):
        dp[i][j] = dp[i - 1][j]
        if 0 <= j - values[i - 1]:
            dp[i][j] = min(dp[i][j], dp[i - 1][j - values[i - 1]] + weights[i - 1])
ans = 0
for i in reversed(list(range(UV + 1))):
    if dp[-1][i] <= w:
        ans = i
        break
print(ans)

-INF = float("inf") -dp = [[0] + [INF] * UV for _ in range(n + 1)] +INF = 10**10 +dp = [[INF] * (UV + 1) for _ in range(n + 1)] +for i in range(n + 1): +    dp[i][0] = 0 -for i in range(UV + 1): +for i in reversed(list(range(UV + 1))): -        ans = max(ans, i) +        ans = i +        break