# Educational DP Contest E-knapsack 2





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

items=[]

for _ in range(N):

    w,v=list(map(int,input().strip().split()))

    items+=[(w,v)]

    

MAX_val=N*10**3+1 # 最大の価値

dp=[[10**9+1]*MAX_val for i in range(N)] # 最大の価値でinitialize(価値の表）

dp[0][items[0][1]]=items[0][0] # 最初の品物の価値の場所に、最初の品物の重さを入れる

for i in range(1,N):

    for val in range(1,MAX_val):

        if val-items[i][1]>0: # アイテムの価値がvalを上回っていた場合

            dp[i][val]=min(dp[i-1][val],dp[i-1][val-items[i][1]]+items[i][0])

        elif val==items[i][1]: # アイテムの価値がvalと同様の場合

            dp[i][val]=min(items[i][0],dp[i-1][val])

        dp[i][val]=min(dp[i][val],dp[i-1][val])



MAX=0

for i in range(len(dp[-1])): # dpの最終行の数を調べて、最もWに近いものを出力

    if dp[-1][i]<=W:

        #print(i)

        MAX=i

print(MAX)

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

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



dp = []

valmax = int(1e5)

INF = int(1e10)

for _ in range(N+1):

    dp.append([INF] * (valmax+1))

dp[0][0] = 0



for i in range(N):

    for v in range(valmax+1):

        dp[i+1][v] = min(dp[i][v], dp[i][v - wv[i][1]] + wv[i][0])



maxval = 0

for k, l in enumerate(dp[N]):

    if l <= W:

        maxval = max(maxval, k)

    else:

        continue

print(maxval)
# Educational DP Contest E-knapsack 2
N, W = list(map(int, input().split()))
items = []
for _ in range(N):
    w, v = list(map(int, input().strip().split()))
    items += [(w, v)]
MAX_val = N * 10**3 + 1  # 最大の価値
dp = [[10**9 + 1] * MAX_val for i in range(N)]  # 最大の価値でinitialize(価値の表）
dp[0][items[0][1]] = items[0][0]  # 最初の品物の価値の場所に、最初の品物の重さを入れる
for i in range(1, N):
    for val in range(1, MAX_val):
        if val - items[i][1] > 0:  # アイテムの価値がvalを上回っていた場合
            dp[i][val] = min(dp[i - 1][val], dp[i - 1][val - items[i][1]] + items[i][0])
        elif val == items[i][1]:  # アイテムの価値がvalと同様の場合
            dp[i][val] = min(items[i][0], dp[i - 1][val])
        dp[i][val] = min(dp[i][val], dp[i - 1][val])
MAX = 0
for i in range(len(dp[-1])):  # dpの最終行の数を調べて、最もWに近いものを出力
    if dp[-1][i] <= W:
        # print(i)
        MAX = i
print(MAX)

N, W = list(map(int, input().split()))
wv = [list(map(int, input().split())) for _ in range(N)]
dp = []
valmax = int(1e5)
INF = int(1e10)
for _ in range(N + 1):
    dp.append([INF] * (valmax + 1))
dp[0][0] = 0
for i in range(N):
    for v in range(valmax + 1):
        dp[i + 1][v] = min(dp[i][v], dp[i][v - wv[i][1]] + wv[i][0])
maxval = 0
for k, l in enumerate(dp[N]):
    if l <= W:
        maxval = max(maxval, k)
    else:
        continue
print(maxval)

-# Educational DP Contest E-knapsack 2 -items = [] -for _ in range(N): -    w, v = list(map(int, input().strip().split())) -    items += [(w, v)] -MAX_val = N * 10**3 + 1  # 最大の価値 -dp = [[10**9 + 1] * MAX_val for i in range(N)]  # 最大の価値でinitialize(価値の表） -dp[0][items[0][1]] = items[0][0]  # 最初の品物の価値の場所に、最初の品物の重さを入れる -for i in range(1, N): -    for val in range(1, MAX_val): -        if val - items[i][1] > 0:  # アイテムの価値がvalを上回っていた場合 -            dp[i][val] = min(dp[i - 1][val], dp[i - 1][val - items[i][1]] + items[i][0]) -        elif val == items[i][1]:  # アイテムの価値がvalと同様の場合 -            dp[i][val] = min(items[i][0], dp[i - 1][val]) -        dp[i][val] = min(dp[i][val], dp[i - 1][val]) -MAX = 0 -for i in range(len(dp[-1])):  # dpの最終行の数を調べて、最もWに近いものを出力 -    if dp[-1][i] <= W: -        # print(i) -        MAX = i -print(MAX) +wv = [list(map(int, input().split())) for _ in range(N)] +dp = [] +valmax = int(1e5) +INF = int(1e10) +for _ in range(N + 1): +    dp.append([INF] * (valmax + 1)) +dp[0][0] = 0 +for i in range(N): +    for v in range(valmax + 1): +        dp[i + 1][v] = min(dp[i][v], dp[i][v - wv[i][1]] + wv[i][0]) +maxval = 0 +for k, l in enumerate(dp[N]): +    if l <= W: +        maxval = max(maxval, k) +    else: +        continue +print(maxval)