N, W = [int(i) for i in input().split()]

weight, value = [0] * (N + 1), [0] * (N + 1)



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

    weight[i], value[i] = [int(i) for i in input().split()]

#%%

sum_value = sum(value)

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

dp[0][0] = 0



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

    for j in range(sum_value + 1):

        if j >= value[i]:

            dp[i][j] = weight[i] + dp[i - 1][j - value[i]]

        

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

        

ans = 0

for i in range(sum_value + 1):

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

        ans = i



print(ans)

N, W = [int(i) for i in input().split()]

weight, value = [0] * (N + 1), [0] * (N + 1)



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

    weight[i], value[i] = [int(i) for i in input().split()]



#%%



sum_value = sum(value)

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

dp[0][0] = 0



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

    for j in range(sum_value + 1):

        if j >= value[i]:

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

        else:

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

        

ans = 0

for i in range(sum_value + 1):

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

        ans = i



print(ans)
N, W = [int(i) for i in input().split()]
weight, value = [0] * (N + 1), [0] * (N + 1)
for i in range(1, N + 1):
    weight[i], value[i] = [int(i) for i in input().split()]
#%%
sum_value = sum(value)
dp = [[float("inf")] * (sum_value + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(1, N + 1):
    for j in range(sum_value + 1):
        if j >= value[i]:
            dp[i][j] = weight[i] + dp[i - 1][j - value[i]]
        dp[i][j] = min(dp[i][j], dp[i - 1][j])
ans = 0
for i in range(sum_value + 1):
    if dp[N][i] <= W:
        ans = i
print(ans)

N, W = [int(i) for i in input().split()]
weight, value = [0] * (N + 1), [0] * (N + 1)
for i in range(1, N + 1):
    weight[i], value[i] = [int(i) for i in input().split()]
#%%
sum_value = sum(value)
dp = [[float("inf")] * (sum_value + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(1, N + 1):
    for j in range(sum_value + 1):
        if j >= value[i]:
            dp[i][j] = min(dp[i - 1][j], weight[i] + dp[i - 1][j - value[i]])
        else:
            dp[i][j] = dp[i - 1][j]
ans = 0
for i in range(sum_value + 1):
    if dp[N][i] <= W:
        ans = i
print(ans)

-            dp[i][j] = weight[i] + dp[i - 1][j - value[i]] -        dp[i][j] = min(dp[i][j], dp[i - 1][j]) +            dp[i][j] = min(dp[i - 1][j], weight[i] + dp[i - 1][j - value[i]]) +        else: +            dp[i][j] = dp[i - 1][j]