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

w, v = [], []

for _ in range(N):

    w_, v_ = list(map(int, input().split()))

    w.append(w_)

    v.append(v_)

V = sum(v)

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

dp[0][0] = 0

for i in range(N):

    for j in range(V+1):

        if j >= v[i]: dp[i+1][j] = min(dp[i][j] ,dp[i][j-v[i]]+w[i])

        else: dp[i+1][j] = dp[i][j]

ans = 0

for i in range(V+1):

    if dp[N][i]<=W: ans=i

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

w_list, v_list = [], []

for _ in range(N):

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

    w_list.append(w)

    v_list.append(v)

sum_v = sum(v_list)+1



dp = [[float('INF')]*(sum_v) for _ in range(N+1)]

dp[0][0] = 0

for i in range(N):

    w, v = w_list[i], v_list[i]

    for j in range(sum_v):

        if v<=j: dp[i+1][j] = min(dp[i][j], dp[i][j-v]+w)

        else: dp[i+1][j] = dp[i][j]

for i in range(sum_v-1, -1, -1):

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

        print(i)

        break
N, W = list(map(int, input().split()))
w, v = [], []
for _ in range(N):
    w_, v_ = list(map(int, input().split()))
    w.append(w_)
    v.append(v_)
V = sum(v)
dp = [[float("INF")] * (V + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
    for j in range(V + 1):
        if j >= v[i]:
            dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i])
        else:
            dp[i + 1][j] = dp[i][j]
ans = 0
for i in range(V + 1):
    if dp[N][i] <= W:
        ans = i
print(ans)

N, W = list(map(int, input().split()))
w_list, v_list = [], []
for _ in range(N):
    w, v = list(map(int, input().split()))
    w_list.append(w)
    v_list.append(v)
sum_v = sum(v_list) + 1
dp = [[float("INF")] * (sum_v) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
    w, v = w_list[i], v_list[i]
    for j in range(sum_v):
        if v <= j:
            dp[i + 1][j] = min(dp[i][j], dp[i][j - v] + w)
        else:
            dp[i + 1][j] = dp[i][j]
for i in range(sum_v - 1, -1, -1):
    if dp[-1][i] <= W:
        print(i)
        break

-w, v = [], [] +w_list, v_list = [], [] -    w_, v_ = list(map(int, input().split())) -    w.append(w_) -    v.append(v_) -V = sum(v) -dp = [[float("INF")] * (V + 1) for _ in range(N + 1)] +    w, v = list(map(int, input().split())) +    w_list.append(w) +    v_list.append(v) +sum_v = sum(v_list) + 1 +dp = [[float("INF")] * (sum_v) for _ in range(N + 1)] -    for j in range(V + 1): -        if j >= v[i]: -            dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]) +    w, v = w_list[i], v_list[i] +    for j in range(sum_v): +        if v <= j: +            dp[i + 1][j] = min(dp[i][j], dp[i][j - v] + w) -ans = 0 -for i in range(V + 1): -    if dp[N][i] <= W: -        ans = i -print(ans) +for i in range(sum_v - 1, -1, -1): +    if dp[-1][i] <= W: +        print(i) +        break