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

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



V = max(w_v, key=lambda x: x[1])[1] * N

# 1~i-1番目の品物から価値の総和がj以下になるように選んだときの重さ

dp = [[float('inf') for _ in range(V+1)] for _ in range(N+1)]

dp[0][0] = 0



for i in range(N):

    w, v = w_v[i]

    for j in range(V+1):

        if j - v >= 0:

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

        else:

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

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



r = 0

for v in range(V+1):

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

        r = v

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

data = []

for _ in range(n):

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

    data.append((w, v))



V = sum([v for _, v in data])

dp = [[float("inf")] * (V + 1) for i in range(n + 1)]

dp[0][0]= 0



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

    w, v = data[i-1]

    for j in range(V + 1):        

        if j - v >= 0:

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

        else:

            dp[i][j] = dp[i - 1][j]



print((max([i for i, x in enumerate(dp[-1]) if x != "inf" and x <= W])))

N, W = list(map(int, input().split()))
w_v = [list(map(int, input().split())) for _ in range(N)]
V = max(w_v, key=lambda x: x[1])[1] * N
# 1~i-1番目の品物から価値の総和がj以下になるように選んだときの重さ
dp = [[float("inf") for _ in range(V + 1)] for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
    w, v = w_v[i]
    for j in range(V + 1):
        if j - v >= 0:
            dp[i + 1][j] = min(dp[i][j - v] + w, dp[i][j])
        else:
            # dp[i+1][j] = min(dp[i][j], dp[i+1][j])
            dp[i + 1][j] = dp[i][j]
r = 0
for v in range(V + 1):
    if dp[N][v] <= W:
        r = v
print(r)

n, W = list(map(int, input().split()))
data = []
for _ in range(n):
    w, v = list(map(int, input().split()))
    data.append((w, v))
V = sum([v for _, v in data])
dp = [[float("inf")] * (V + 1) for i in range(n + 1)]
dp[0][0] = 0
for i in range(1, n + 1):
    w, v = data[i - 1]
    for j in range(V + 1):
        if j - v >= 0:
            dp[i][j] = min(dp[i - 1][j - v] + w, dp[i - 1][j])
        else:
            dp[i][j] = dp[i - 1][j]
print((max([i for i, x in enumerate(dp[-1]) if x != "inf" and x <= W])))

-N, W = list(map(int, input().split())) -w_v = [list(map(int, input().split())) for _ in range(N)] -V = max(w_v, key=lambda x: x[1])[1] * N -# 1~i-1番目の品物から価値の総和がj以下になるように選んだときの重さ -dp = [[float("inf") for _ in range(V + 1)] for _ in range(N + 1)] +n, W = list(map(int, input().split())) +data = [] +for _ in range(n): +    w, v = list(map(int, input().split())) +    data.append((w, v)) +V = sum([v for _, v in data]) +dp = [[float("inf")] * (V + 1) for i in range(n + 1)] -for i in range(N): -    w, v = w_v[i] +for i in range(1, n + 1): +    w, v = data[i - 1] -            dp[i + 1][j] = min(dp[i][j - v] + w, dp[i][j]) +            dp[i][j] = min(dp[i - 1][j - v] + w, dp[i - 1][j]) -            # dp[i+1][j] = min(dp[i][j], dp[i+1][j]) -            dp[i + 1][j] = dp[i][j] -r = 0 -for v in range(V + 1): -    if dp[N][v] <= W: -        r = v -print(r) +            dp[i][j] = dp[i - 1][j] +print((max([i for i, x in enumerate(dp[-1]) if x != "inf" and x <= W])))