# E - Knapsack 2

from collections import defaultdict





def main():

    INF = 1 << 30

    N, W, *WV = list(map(int, open(0).read().split()))

    dp = defaultdict(lambda: INF)  # dp[i] := minimum weight at value i

    dp[0] = 0

    for w, v in zip(*[iter(WV)] * 2):

        for cur_v, cur_w in tuple(dp.items()):

            if w + cur_w <= W:

                dp[v + cur_v] = min(dp[v + cur_v], w + cur_w)

    print((max(dp.keys())))





if __name__ == "__main__":

    main()

# E - Knapsack 2

def knapsack_heavy(limit: int, weight: list, value: list) -> int:

    lim = sum(value)

    dp = [0] + [1 << 30] * lim  # dp[i] := minimum weight at value i

    for w, v in zip(weight, value):

        for cur_v in range(lim, v - 1, -1):

            dp[cur_v] = min(dp[cur_v], dp[cur_v - v] + w)

    ret = max(v for v, w in enumerate(dp) if w <= limit)

    return ret





def main():

    N, W, *WV = list(map(int, open(0).read().split()))

    print((knapsack_heavy(W, WV[::2], WV[1::2])))





if __name__ == "__main__":

    main()

# E - Knapsack 2
from collections import defaultdict


def main():
    INF = 1 << 30
    N, W, *WV = list(map(int, open(0).read().split()))
    dp = defaultdict(lambda: INF)  # dp[i] := minimum weight at value i
    dp[0] = 0
    for w, v in zip(*[iter(WV)] * 2):
        for cur_v, cur_w in tuple(dp.items()):
            if w + cur_w <= W:
                dp[v + cur_v] = min(dp[v + cur_v], w + cur_w)
    print((max(dp.keys())))


if __name__ == "__main__":
    main()

# E - Knapsack 2
def knapsack_heavy(limit: int, weight: list, value: list) -> int:
    lim = sum(value)
    dp = [0] + [1 << 30] * lim  # dp[i] := minimum weight at value i
    for w, v in zip(weight, value):
        for cur_v in range(lim, v - 1, -1):
            dp[cur_v] = min(dp[cur_v], dp[cur_v - v] + w)
    ret = max(v for v, w in enumerate(dp) if w <= limit)
    return ret


def main():
    N, W, *WV = list(map(int, open(0).read().split()))
    print((knapsack_heavy(W, WV[::2], WV[1::2])))


if __name__ == "__main__":
    main()

-from collections import defaultdict +def knapsack_heavy(limit: int, weight: list, value: list) -> int: +    lim = sum(value) +    dp = [0] + [1 << 30] * lim  # dp[i] := minimum weight at value i +    for w, v in zip(weight, value): +        for cur_v in range(lim, v - 1, -1): +            dp[cur_v] = min(dp[cur_v], dp[cur_v - v] + w) +    ret = max(v for v, w in enumerate(dp) if w <= limit) +    return ret -    INF = 1 << 30 -    dp = defaultdict(lambda: INF)  # dp[i] := minimum weight at value i -    dp[0] = 0 -    for w, v in zip(*[iter(WV)] * 2): -        for cur_v, cur_w in tuple(dp.items()): -            if w + cur_w <= W: -                dp[v + cur_v] = min(dp[v + cur_v], w + cur_w) -    print((max(dp.keys()))) +    print((knapsack_heavy(W, WV[::2], WV[1::2])))