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

V, W = [], []

for i in range(n):

    wi, vi = list(map(int, input().split()))

    W.append(wi)

    V.append(vi)

    

max_sumv = sum(V) 

# dp[i][sum_v] := i-1 番目までの品物から価値がsum_v以上を達成するように選んだときの、重さの総和の最小値   

dp = [[10 ** 9] * (max_sumv + 1) for _ in range(n+1)]



dp[0][0] = 0

for i in range(n):

    for sum_v in range(max_sumv + 1):

        #i番目の商品を選ぶ場合

        if sum_v - V[i] >= 0:

            dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - V[i]] + W[i])

        #i番目の商品を選ばない場合

        dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])

ans = 0

for i in range(max_sumv + 1):

    if dp[n][i] <= w:

        ans = i

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

W, V = [], []

sum_v = 0

for i in range(n):

  wi, vi = list(map(int ,input().split()))

  W.append(wi)

  V.append(vi)

  sum_v += vi



memo = [[10**9] * (sum_v + 1) for _ in range(n+1)]

memo[0][0] = 0



for i in range(n):

  for v_i in range(sum_v + 1):

    memo[i+1][v_i] = min(memo[i+1][v_i], memo[i][v_i])

    if v_i - V[i] >= 0:

      memo[i+1][v_i] = min(memo[i+1][v_i], memo[i][v_i-V[i]] + W[i])



ans = 0

for i in range(sum_v + 1):

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

    ans = i

print(ans)
n, w = list(map(int, input().split()))
V, W = [], []
for i in range(n):
    wi, vi = list(map(int, input().split()))
    W.append(wi)
    V.append(vi)
max_sumv = sum(V)
# dp[i][sum_v] := i-1 番目までの品物から価値がsum_v以上を達成するように選んだときの、重さの総和の最小値
dp = [[10**9] * (max_sumv + 1) for _ in range(n + 1)]
dp[0][0] = 0
for i in range(n):
    for sum_v in range(max_sumv + 1):
        # i番目の商品を選ぶ場合
        if sum_v - V[i] >= 0:
            dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v - V[i]] + W[i])
        # i番目の商品を選ばない場合
        dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v])
ans = 0
for i in range(max_sumv + 1):
    if dp[n][i] <= w:
        ans = i
print(ans)

n, w = list(map(int, input().split()))
W, V = [], []
sum_v = 0
for i in range(n):
    wi, vi = list(map(int, input().split()))
    W.append(wi)
    V.append(vi)
    sum_v += vi
memo = [[10**9] * (sum_v + 1) for _ in range(n + 1)]
memo[0][0] = 0
for i in range(n):
    for v_i in range(sum_v + 1):
        memo[i + 1][v_i] = min(memo[i + 1][v_i], memo[i][v_i])
        if v_i - V[i] >= 0:
            memo[i + 1][v_i] = min(memo[i + 1][v_i], memo[i][v_i - V[i]] + W[i])
ans = 0
for i in range(sum_v + 1):
    if memo[-1][i] <= w:
        ans = i
print(ans)

-V, W = [], [] +W, V = [], [] +sum_v = 0 -max_sumv = sum(V) -# dp[i][sum_v] := i-1 番目までの品物から価値がsum_v以上を達成するように選んだときの、重さの総和の最小値 -dp = [[10**9] * (max_sumv + 1) for _ in range(n + 1)] -dp[0][0] = 0 +    sum_v += vi +memo = [[10**9] * (sum_v + 1) for _ in range(n + 1)] +memo[0][0] = 0 -    for sum_v in range(max_sumv + 1): -        # i番目の商品を選ぶ場合 -        if sum_v - V[i] >= 0: -            dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v - V[i]] + W[i]) -        # i番目の商品を選ばない場合 -        dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v]) +    for v_i in range(sum_v + 1): +        memo[i + 1][v_i] = min(memo[i + 1][v_i], memo[i][v_i]) +        if v_i - V[i] >= 0: +            memo[i + 1][v_i] = min(memo[i + 1][v_i], memo[i][v_i - V[i]] + W[i]) -for i in range(max_sumv + 1): -    if dp[n][i] <= w: +for i in range(sum_v + 1): +    if memo[-1][i] <= w: