MAX_V = 100100

MAX_N = 101

INF = pow(2, 63)



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

w = [0 for _ in range(N)]

v = [0 for _ in range(N)]

for i in range(N):

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



dp = [[INF for _ in range(MAX_V)] for _ in range(N + 1)]

dp[0][0] = 0

for i in range(N):

    for sum_v in range(MAX_V):

        # print(i, sum_v, sum_v - v[i] >= 0)

        if sum_v - v[i] >= 0:

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

        dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])

        # print(dp[i + 1][sum_v])



ans = max([i for i in range(len(dp[N])) if dp[N][i] <= W])

# for l in dp:

#     print([n for n in l if not n == INF])



print(ans)

MAX_V = 100100

MAX_N = 101

INF = pow(2, 62)



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

w = [0 for _ in range(N)]

v = [0 for _ in range(N)]

for i in range(N):

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



dp = [[INF for _ in range(MAX_V)] for _ in range(N + 1)]

dp[0][0] = 0

for i in range(N):

    for sum_v in range(MAX_V):

        # print(i, sum_v, sum_v - v[i] >= 0)

        if sum_v - v[i] >= 0:

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

        dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])

        # print(dp[i + 1][sum_v])



ans = max([i for i in range(len(dp[N])) if dp[N][i] <= W])

# for l in dp:

#     print([n for n in l if not n == INF])



print(ans)

MAX_V = 100100
MAX_N = 101
INF = pow(2, 63)
N, W = list(map(int, input().split()))
w = [0 for _ in range(N)]
v = [0 for _ in range(N)]
for i in range(N):
    w[i], v[i] = list(map(int, input().split()))
dp = [[INF for _ in range(MAX_V)] for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
    for sum_v in range(MAX_V):
        # print(i, sum_v, sum_v - v[i] >= 0)
        if sum_v - v[i] >= 0:
            dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v - v[i]] + w[i])
        dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v])
        # print(dp[i + 1][sum_v])
ans = max([i for i in range(len(dp[N])) if dp[N][i] <= W])
# for l in dp:
#     print([n for n in l if not n == INF])
print(ans)

MAX_V = 100100
MAX_N = 101
INF = pow(2, 62)
N, W = list(map(int, input().split()))
w = [0 for _ in range(N)]
v = [0 for _ in range(N)]
for i in range(N):
    w[i], v[i] = list(map(int, input().split()))
dp = [[INF for _ in range(MAX_V)] for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
    for sum_v in range(MAX_V):
        # print(i, sum_v, sum_v - v[i] >= 0)
        if sum_v - v[i] >= 0:
            dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v - v[i]] + w[i])
        dp[i + 1][sum_v] = min(dp[i + 1][sum_v], dp[i][sum_v])
        # print(dp[i + 1][sum_v])
ans = max([i for i in range(len(dp[N])) if dp[N][i] <= W])
# for l in dp:
#     print([n for n in l if not n == INF])
print(ans)

-INF = pow(2, 63) +INF = pow(2, 62)