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

wv = []

vsum=0

for _ in range(n):

    tmp = list(map(int,input().split()))

    wv.append(tmp)

    vsum += tmp[1]



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

dp[0][0]=0



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

    now_w,now_v =wv[i-1]

    for v in range(vsum+1):

        dp[i][v] = dp[i-1][v]

        if v - now_v >= 0:

            dp[i][v] = min(dp[i][v],dp[i-1][v-now_v] + now_w)



ans=0

for val in range(len(dp[-1])):

    if dp[-1][val] <= w:

        ans=val

print(ans)
n,w = list(map(int, input().split()))

wv = []

vsum=0

for _ in range(n):

    tmp = list(map(int,input().split()))

    wv.append(tmp)

    vsum += tmp[1]



INF = 1 << 30



dp = [[INF for i in range(vsum+1)] for j in range(n+1)]

dp[0][0]=0



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

    now_w,now_v =wv[i-1]

    for v in range(vsum+1):

        dp[i][v] = dp[i-1][v]

        if v - now_v >= 0:

            dp[i][v] = min(dp[i][v],dp[i-1][v-now_v] + now_w)



ans=0

for val in range(len(dp[-1])):

    if dp[-1][val] <= w:

        ans=val

print(ans)
n, w = list(map(int, input().split()))
wv = []
vsum = 0
for _ in range(n):
    tmp = list(map(int, input().split()))
    wv.append(tmp)
    vsum += tmp[1]
dp = [[float("inf") for i in range(vsum + 1)] for j in range(n + 1)]
dp[0][0] = 0
for i in range(1, n + 1):
    now_w, now_v = wv[i - 1]
    for v in range(vsum + 1):
        dp[i][v] = dp[i - 1][v]
        if v - now_v >= 0:
            dp[i][v] = min(dp[i][v], dp[i - 1][v - now_v] + now_w)
ans = 0
for val in range(len(dp[-1])):
    if dp[-1][val] <= w:
        ans = val
print(ans)

n, w = list(map(int, input().split()))
wv = []
vsum = 0
for _ in range(n):
    tmp = list(map(int, input().split()))
    wv.append(tmp)
    vsum += tmp[1]
INF = 1 << 30
dp = [[INF for i in range(vsum + 1)] for j in range(n + 1)]
dp[0][0] = 0
for i in range(1, n + 1):
    now_w, now_v = wv[i - 1]
    for v in range(vsum + 1):
        dp[i][v] = dp[i - 1][v]
        if v - now_v >= 0:
            dp[i][v] = min(dp[i][v], dp[i - 1][v - now_v] + now_w)
ans = 0
for val in range(len(dp[-1])):
    if dp[-1][val] <= w:
        ans = val
print(ans)

-dp = [[float("inf") for i in range(vsum + 1)] for j in range(n + 1)] +INF = 1 << 30 +dp = [[INF for i in range(vsum + 1)] for j in range(n + 1)]