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

L = list(list(map(int,input().split())) for i in range(N))



upper = 10**5

dp = [float("inf") for i in range(upper+1)]

dp[0] = 0



for item in range(N) :

    weight_i,value_i = L[item]

    for value in range(upper, value_i-1, -1) :

        if dp[value - value_i] + weight_i <= W :

            dp[value] = min(dp[value], dp[value - value_i] + weight_i)



for value in range(upper, -1, -1) :

    if dp[value] < float("inf") :

        ans = value

        break



print(ans)

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

L = list(list(map(int,input().split())) for i in range(N))

upper = 10**5

dp = [float("inf") for i in range(upper+1)] #dp[i] = "価値の総和=i"の最小重さ

dp[0] = 0



for item in range(N) :

    weight_i,value_i = L[item]

    for value in range(upper, value_i-1, -1) :

        if dp[value - value_i] + weight_i <= W :

            dp[value] = min(dp[value], dp[value - value_i] + weight_i)



for value in range(upper, -1, -1) :

    if dp[value] < float("inf") :

        ans = value

        break



print(ans)

N, W = list(map(int, input().split()))
L = list(list(map(int, input().split())) for i in range(N))
upper = 10**5
dp = [float("inf") for i in range(upper + 1)]
dp[0] = 0
for item in range(N):
    weight_i, value_i = L[item]
    for value in range(upper, value_i - 1, -1):
        if dp[value - value_i] + weight_i <= W:
            dp[value] = min(dp[value], dp[value - value_i] + weight_i)
for value in range(upper, -1, -1):
    if dp[value] < float("inf"):
        ans = value
        break
print(ans)

N, W = list(map(int, input().split()))
L = list(list(map(int, input().split())) for i in range(N))
upper = 10**5
dp = [float("inf") for i in range(upper + 1)]  # dp[i] = "価値の総和=i"の最小重さ
dp[0] = 0
for item in range(N):
    weight_i, value_i = L[item]
    for value in range(upper, value_i - 1, -1):
        if dp[value - value_i] + weight_i <= W:
            dp[value] = min(dp[value], dp[value - value_i] + weight_i)
for value in range(upper, -1, -1):
    if dp[value] < float("inf"):
        ans = value
        break
print(ans)

-dp = [float("inf") for i in range(upper + 1)] +dp = [float("inf") for i in range(upper + 1)]  # dp[i] = "価値の総和=i"の最小重さ