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

w=[]

v=[]

for i in range(N):

    x,y=list(map(int,input().split()))

    w+=[x]

    v+=[y]



V_sum=sum(v)+1

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

dp[0][0]=0

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

    for sum_v in range(V_sum):

        #同価値の場合より軽いほうを入れる

        if sum_v-v[i-1]>=0:

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



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



ans=0

for i in range(V_sum):

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

        ans=i

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

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

inf = 10 ** 10

dp = [[inf] * (1000 * n + 1) for i in range(n + 1)]

dp[0][0] = 0



for i in range(n):

    for j in range(1000 * n + 1):

        if dp[i][j] == inf:continue

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



        w, v = wv[i]

        if dp[i][j] + w <= W:

            dp[i + 1][j + v] = min(dp[i + 1][j + v], dp[i][j] + w)



for i in range(1000 * n + 1):

    if dp[-1][-(i + 1)] != inf:

        print((1000 * n - i))

        exit()
N, W = list(map(int, input().split()))
w = []
v = []
for i in range(N):
    x, y = list(map(int, input().split()))
    w += [x]
    v += [y]
V_sum = sum(v) + 1
dp = [[float("inf")] * (V_sum) for i in range(N + 1)]
dp[0][0] = 0
for i in range(1, N + 1):
    for sum_v in range(V_sum):
        # 同価値の場合より軽いほうを入れる
        if sum_v - v[i - 1] >= 0:
            dp[i][sum_v] = min(dp[i][sum_v], dp[i - 1][sum_v - v[i - 1]] + w[i - 1])
        dp[i][sum_v] = min(dp[i - 1][sum_v], dp[i][sum_v])
ans = 0
for i in range(V_sum):
    if dp[-1][i] <= W and ans < i:
        ans = i
print(ans)

n, W = list(map(int, input().split()))
wv = [list(map(int, input().split())) for i in range(n)]
inf = 10**10
dp = [[inf] * (1000 * n + 1) for i in range(n + 1)]
dp[0][0] = 0
for i in range(n):
    for j in range(1000 * n + 1):
        if dp[i][j] == inf:
            continue
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
        w, v = wv[i]
        if dp[i][j] + w <= W:
            dp[i + 1][j + v] = min(dp[i + 1][j + v], dp[i][j] + w)
for i in range(1000 * n + 1):
    if dp[-1][-(i + 1)] != inf:
        print((1000 * n - i))
        exit()

-N, W = list(map(int, input().split())) -w = [] -v = [] -for i in range(N): -    x, y = list(map(int, input().split())) -    w += [x] -    v += [y] -V_sum = sum(v) + 1 -dp = [[float("inf")] * (V_sum) for i in range(N + 1)] +n, W = list(map(int, input().split())) +wv = [list(map(int, input().split())) for i in range(n)] +inf = 10**10 +dp = [[inf] * (1000 * n + 1) for i in range(n + 1)] -for i in range(1, N + 1): -    for sum_v in range(V_sum): -        # 同価値の場合より軽いほうを入れる -        if sum_v - v[i - 1] >= 0: -            dp[i][sum_v] = min(dp[i][sum_v], dp[i - 1][sum_v - v[i - 1]] + w[i - 1]) -        dp[i][sum_v] = min(dp[i - 1][sum_v], dp[i][sum_v]) -ans = 0 -for i in range(V_sum): -    if dp[-1][i] <= W and ans < i: -        ans = i -print(ans) +for i in range(n): +    for j in range(1000 * n + 1): +        if dp[i][j] == inf: +            continue +        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]) +        w, v = wv[i] +        if dp[i][j] + w <= W: +            dp[i + 1][j + v] = min(dp[i + 1][j + v], dp[i][j] + w) +for i in range(1000 * n + 1): +    if dp[-1][-(i + 1)] != inf: +        print((1000 * n - i)) +        exit()