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

w = [0]*(n+1)

v = [0]*(n+1)

for i in range(1,n+1): w[i],v[i] = list(map(int,input().split()))

mv = n*max(v)

dp = [[float("INF")]*(mv+1) for _ in range(n+1)]

for i in range(n): dp[i][0] = 0

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

    for s in range(1,mv+1):

        if s - v[i] < 0: dp[i][s] = dp[i-1][s]

        else: dp[i][s] = min(dp[i-1][s], dp[i-1][s-v[i]] + w[i])

ans = 0

for x in range(1,mv+1):

    if dp[n][x] <= W: ans = x

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

w = [0]*n

v = [0]*n

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

mv = n*max(v)

dp = [[float("INF")]*(mv+1) for _ in range(n+1)]

dp[0][0] = 0

for i in range(n):

    for s in range(mv+1):

        if s - v[i] < 0: dp[i+1][s] = dp[i][s]

        else: dp[i+1][s] = min(dp[i][s], dp[i][s-v[i]] + w[i])

ans = 0

for x in range(1,mv+1):

    if dp[n][x] <= W: ans = x

print(ans)
n, W = list(map(int, input().split()))
w = [0] * (n + 1)
v = [0] * (n + 1)
for i in range(1, n + 1):
    w[i], v[i] = list(map(int, input().split()))
mv = n * max(v)
dp = [[float("INF")] * (mv + 1) for _ in range(n + 1)]
for i in range(n):
    dp[i][0] = 0
for i in range(1, n + 1):
    for s in range(1, mv + 1):
        if s - v[i] < 0:
            dp[i][s] = dp[i - 1][s]
        else:
            dp[i][s] = min(dp[i - 1][s], dp[i - 1][s - v[i]] + w[i])
ans = 0
for x in range(1, mv + 1):
    if dp[n][x] <= W:
        ans = x
print(ans)

n, W = list(map(int, input().split()))
w = [0] * n
v = [0] * n
for i in range(n):
    w[i], v[i] = list(map(int, input().split()))
mv = n * max(v)
dp = [[float("INF")] * (mv + 1) for _ in range(n + 1)]
dp[0][0] = 0
for i in range(n):
    for s in range(mv + 1):
        if s - v[i] < 0:
            dp[i + 1][s] = dp[i][s]
        else:
            dp[i + 1][s] = min(dp[i][s], dp[i][s - v[i]] + w[i])
ans = 0
for x in range(1, mv + 1):
    if dp[n][x] <= W:
        ans = x
print(ans)

-w = [0] * (n + 1) -v = [0] * (n + 1) -for i in range(1, n + 1): +w = [0] * n +v = [0] * n +for i in range(n): +dp[0][0] = 0 -    dp[i][0] = 0 -for i in range(1, n + 1): -    for s in range(1, mv + 1): +    for s in range(mv + 1): -            dp[i][s] = dp[i - 1][s] +            dp[i + 1][s] = dp[i][s] -            dp[i][s] = min(dp[i - 1][s], dp[i - 1][s - v[i]] + w[i]) +            dp[i + 1][s] = min(dp[i][s], dp[i][s - v[i]] + w[i])