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

L = [list(map(int, input().split())) for i in range(N)]

V = 0

for i in range(N):

  V += L[i][1]



dp = [[10**9+1] * (V + 1) for i in range(N+1)]

dp[0][0] = 0

for i in range(N):

    for j in range(V+1):

        if j - L[i][1] >= 0:

          dp[i+1][j] = min(dp[i][j], dp[i][j-L[i][1]] + L[i][0])

        else:

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

ans = 0

for j in range(V+1):

    if  W >= dp[-1][j]:

        ans = max(ans, j)

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

L = [list(map(int, input().split())) for i in range(N)]

V = 0

for i in range(N):

  V += L[i][1]



dp = [10**9+1] * (V + 1)

dp[0] = 0

for i in range(N):

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

        dp[j] = min(dp[j], dp[j-L[i][1]] + L[i][0])

ans = 0

for j in range(V+1):

    if  W >= dp[j]:

        ans = max(ans, j)

print(ans)
N, W = list(map(int, input().split()))
L = [list(map(int, input().split())) for i in range(N)]
V = 0
for i in range(N):
    V += L[i][1]
dp = [[10**9 + 1] * (V + 1) for i in range(N + 1)]
dp[0][0] = 0
for i in range(N):
    for j in range(V + 1):
        if j - L[i][1] >= 0:
            dp[i + 1][j] = min(dp[i][j], dp[i][j - L[i][1]] + L[i][0])
        else:
            dp[i + 1][j] = dp[i][j]
ans = 0
for j in range(V + 1):
    if W >= dp[-1][j]:
        ans = max(ans, j)
print(ans)

N, W = list(map(int, input().split()))
L = [list(map(int, input().split())) for i in range(N)]
V = 0
for i in range(N):
    V += L[i][1]
dp = [10**9 + 1] * (V + 1)
dp[0] = 0
for i in range(N):
    for j in range(V, -1, -1):
        dp[j] = min(dp[j], dp[j - L[i][1]] + L[i][0])
ans = 0
for j in range(V + 1):
    if W >= dp[j]:
        ans = max(ans, j)
print(ans)

-dp = [[10**9 + 1] * (V + 1) for i in range(N + 1)] -dp[0][0] = 0 +dp = [10**9 + 1] * (V + 1) +dp[0] = 0 -    for j in range(V + 1): -        if j - L[i][1] >= 0: -            dp[i + 1][j] = min(dp[i][j], dp[i][j - L[i][1]] + L[i][0]) -        else: -            dp[i + 1][j] = dp[i][j] +    for j in range(V, -1, -1): +        dp[j] = min(dp[j], dp[j - L[i][1]] + L[i][0]) -    if W >= dp[-1][j]: +    if W >= dp[j]: