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

m=10**5+1

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

dp=[[float('inf')]*m for i in range(n+1)]

dp[0][0]=0

for i in range(n):

    for j in range(m):

        if j>=x[i][1]:

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

        else:

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

ans=0

for i in range(m):

    if dp[-1][i]<=w:ans=max(ans,i)

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()))
m = 10**5 + 1
x = [list(map(int, input().split())) for i in range(n)]
dp = [[float("inf")] * m for i in range(n + 1)]
dp[0][0] = 0
for i in range(n):
    for j in range(m):
        if j >= x[i][1]:
            dp[i + 1][j] = min(dp[i][j], dp[i][j - x[i][1]] + x[i][0])
        else:
            dp[i + 1][j] = dp[i][j]
ans = 0
for i in range(m):
    if dp[-1][i] <= w:
        ans = max(ans, i)
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())) -m = 10**5 + 1 -x = [list(map(int, input().split())) for i in range(n)] -dp = [[float("inf")] * m for i in range(n + 1)] +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)] -for i in range(n): -    for j in range(m): -        if j >= x[i][1]: -            dp[i + 1][j] = min(dp[i][j], dp[i][j - x[i][1]] + x[i][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]) -for i in range(m): -    if dp[-1][i] <= w: -        ans = max(ans, i) +for j in range(V + 1): +    if W >= dp[-1][j]: +        ans = max(ans, j)