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 = [[float('inf')] * (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) 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 = [[float("inf")] * (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) 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)

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