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

weight,value=[],[]

for i in range(N):

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

    weight.append(w)

    value.append(v)

inf = float('inf')

dp = [[inf for _ in range(10**3*N+10)] for _ in range(N+10)]

maxv = sum(value)

#初期化

dp[0][0] =0

for i in range(N):

    for sum_v in range(maxv+1):

        if sum_v-value[i] >=0:

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

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

res =0

for sum_v in range(maxv+1):

    if dp[N][sum_v] <=W:

        res = sum_v

print(res)
N,maxW = list(map(int,input().split()))

w,v = [],[]

for i in range(N):

    weight,value = list(map(int,input().split()))

    w.append(weight)

    v.append(value)

maxV=sum(v)

inf = float('inf')

dp = [[inf for _ in range(maxV+1)] for _ in range(N+1)]

dp[0][0] =0

for i in range(N):

    for sum_v in range(maxV+1):

        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])

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

res = 0

for i in range(maxV+1):

    if dp[N][i] <= maxW:

        res = i

print(res)
N, W = list(map(int, input().split()))
weight, value = [], []
for i in range(N):
    w, v = list(map(int, input().split()))
    weight.append(w)
    value.append(v)
inf = float("inf")
dp = [[inf for _ in range(10**3 * N + 10)] for _ in range(N + 10)]
maxv = sum(value)
# 初期化
dp[0][0] = 0
for i in range(N):
    for sum_v in range(maxv + 1):
        if sum_v - value[i] >= 0:
            dp[i + 1][sum_v] = min(
                dp[i + 1][sum_v], dp[i][sum_v - value[i]] + weight[i]
            )
        dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v])
res = 0
for sum_v in range(maxv + 1):
    if dp[N][sum_v] <= W:
        res = sum_v
print(res)

N, maxW = list(map(int, input().split()))
w, v = [], []
for i in range(N):
    weight, value = list(map(int, input().split()))
    w.append(weight)
    v.append(value)
maxV = sum(v)
inf = float("inf")
dp = [[inf for _ in range(maxV + 1)] for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
    for sum_v in range(maxV + 1):
        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])
        dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v])
res = 0
for i in range(maxV + 1):
    if dp[N][i] <= maxW:
        res = i
print(res)

-N, W = list(map(int, input().split())) -weight, value = [], [] +N, maxW = list(map(int, input().split())) +w, v = [], [] -    w, v = list(map(int, input().split())) -    weight.append(w) -    value.append(v) +    weight, value = list(map(int, input().split())) +    w.append(weight) +    v.append(value) +maxV = sum(v) -dp = [[inf for _ in range(10**3 * N + 10)] for _ in range(N + 10)] -maxv = sum(value) -# 初期化 +dp = [[inf for _ in range(maxV + 1)] for _ in range(N + 1)] -    for sum_v in range(maxv + 1): -        if sum_v - value[i] >= 0: -            dp[i + 1][sum_v] = min( -                dp[i + 1][sum_v], dp[i][sum_v - value[i]] + weight[i] -            ) +    for sum_v in range(maxV + 1): +        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]) -for sum_v in range(maxv + 1): -    if dp[N][sum_v] <= W: -        res = sum_v +for i in range(maxV + 1): +    if dp[N][i] <= maxW: +        res = i