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



MAX_V = N * (10 ** 3)

w, v = [], []

for _ in range(N):

    a, b = list(map(int, input().split()))

    w.append(a)

    v.append(b)



dp = [[10**9+7 for _ in range(MAX_V + 1)] for _ in range(N + 1)]

dp[0][0] = 0



for i in range(N):

    for j in range(MAX_V + 1):

        if j - v[i] >= 0:

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

        else:

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



mv = 0

for i in range(MAX_V + 1):

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

        mv = i

print(mv)

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



MAX_V = N * (10 ** 3)

w, v = [], []

for _ in range(N):

    a, b = list(map(int, input().split()))

    w.append(a)

    v.append(b)



dp = [10**9+7 for _ in range(MAX_V + 1)]

dp[0] = 0



for i in range(N):

    for j in range(MAX_V, -1, -1):

        if j - v[i] >= 0:

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

        else:

            dp[j] = dp[j]



mv = 0

for i in range(MAX_V + 1):

    if dp[i] <= W:

        mv = i



print(mv)

N, W = list(map(int, input().split()))
MAX_V = N * (10**3)
w, v = [], []
for _ in range(N):
    a, b = list(map(int, input().split()))
    w.append(a)
    v.append(b)
dp = [[10**9 + 7 for _ in range(MAX_V + 1)] for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
    for j in range(MAX_V + 1):
        if j - v[i] >= 0:
            dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i])
        else:
            dp[i + 1][j] = dp[i][j]
mv = 0
for i in range(MAX_V + 1):
    if dp[N][i] <= W:
        mv = i
print(mv)

N, W = list(map(int, input().split()))
MAX_V = N * (10**3)
w, v = [], []
for _ in range(N):
    a, b = list(map(int, input().split()))
    w.append(a)
    v.append(b)
dp = [10**9 + 7 for _ in range(MAX_V + 1)]
dp[0] = 0
for i in range(N):
    for j in range(MAX_V, -1, -1):
        if j - v[i] >= 0:
            dp[j] = min(dp[j], dp[j - v[i]] + w[i])
        else:
            dp[j] = dp[j]
mv = 0
for i in range(MAX_V + 1):
    if dp[i] <= W:
        mv = i
print(mv)

-dp = [[10**9 + 7 for _ in range(MAX_V + 1)] for _ in range(N + 1)] -dp[0][0] = 0 +dp = [10**9 + 7 for _ in range(MAX_V + 1)] +dp[0] = 0 -    for j in range(MAX_V + 1): +    for j in range(MAX_V, -1, -1): -            dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]) +            dp[j] = min(dp[j], dp[j - v[i]] + w[i]) -            dp[i + 1][j] = dp[i][j] +            dp[j] = dp[j] -    if dp[N][i] <= W: +    if dp[i] <= W: