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

c = [tuple(map(int,input().split())) for i in range(N)]

DP = [[float('inf') for i in range(10**3*N+1)] for i in range(N+1)]

DP[0][0] = 0

for i in range(N):

    for v in range(10**3*N+1):

        if v-c[i][1] < 0:

            DP[i+1][v] = DP[i][v]

        else:

            DP[i+1][v] = min(DP[i][v-c[i][1]]+c[i][0],DP[i][v])



ans = 0

DP = DP[N]

for v in range(10**3*N,-1,-1):

    if DP[v] <= W:

        ans = v

        break

print(ans)
INF = float('inf')

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

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

V = 1000*N

dp = [[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-wv[i][1] >= 0:

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

        else:

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



ans = 0

for i in range(N+1):

    for j in range(V+1):

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

            ans = max(ans,j)

print(ans)
N, W = list(map(int, input().split()))
c = [tuple(map(int, input().split())) for i in range(N)]
DP = [[float("inf") for i in range(10**3 * N + 1)] for i in range(N + 1)]
DP[0][0] = 0
for i in range(N):
    for v in range(10**3 * N + 1):
        if v - c[i][1] < 0:
            DP[i + 1][v] = DP[i][v]
        else:
            DP[i + 1][v] = min(DP[i][v - c[i][1]] + c[i][0], DP[i][v])
ans = 0
DP = DP[N]
for v in range(10**3 * N, -1, -1):
    if DP[v] <= W:
        ans = v
        break
print(ans)

INF = float("inf")
N, W = list(map(int, input().split()))
wv = [list(map(int, input().split())) for _ in range(N)]
V = 1000 * N
dp = [[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 - wv[i][1] >= 0:
            dp[i + 1][j] = min(dp[i][j - wv[i][1]] + wv[i][0], dp[i][j])
        else:
            dp[i + 1][j] = dp[i][j]
ans = 0
for i in range(N + 1):
    for j in range(V + 1):
        if dp[i][j] <= W:
            ans = max(ans, j)
print(ans)

+INF = float("inf") -c = [tuple(map(int, input().split())) for i in range(N)] -DP = [[float("inf") for i in range(10**3 * N + 1)] for i in range(N + 1)] -DP[0][0] = 0 +wv = [list(map(int, input().split())) for _ in range(N)] +V = 1000 * N +dp = [[INF] * (V + 1) for _ in range(N + 1)] +dp[0][0] = 0 -    for v in range(10**3 * N + 1): -        if v - c[i][1] < 0: -            DP[i + 1][v] = DP[i][v] +    for j in range(V + 1): +        if j - wv[i][1] >= 0: +            dp[i + 1][j] = min(dp[i][j - wv[i][1]] + wv[i][0], dp[i][j]) -            DP[i + 1][v] = min(DP[i][v - c[i][1]] + c[i][0], DP[i][v]) +            dp[i + 1][j] = dp[i][j] -DP = DP[N] -for v in range(10**3 * N, -1, -1): -    if DP[v] <= W: -        ans = v -        break +for i in range(N + 1): +    for j in range(V + 1): +        if dp[i][j] <= W: +            ans = max(ans, j)