def main():

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

    Ws = []

    Vs = []

    for _ in range(N):

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

        Ws.append(w)

        Vs.append(v)

    mv = sum(Vs)

    dp = [[float('INF')] * (mv + 1) for _ in range(N + 1)]

    dp[0][0] = 0

    for i in range(N):

        for j in range(mv + 1):

            if Vs[i] > j:

                dp[i + 1][j] = dp[i][j]

            else:

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

    for j in range(mv, -1, -1):

        if W >= dp[N][j]:

            print(j)

            break





main()

def main():

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

    MV = 10**5

    dp = [float('INF')] * (MV + 1)

    dp[0] = 0

    for _ in range(N):

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

        for i in range(MV, -1, -1):

            if v > i:

                tmp = w

            else:

                tmp = dp[i - v] + w

            dp[i] = min(dp[i], tmp)

    ans = 0

    for v, w in enumerate(dp):

        if W >= w:

            ans = max(ans, v)

        else:

            break

    print(ans)





main()

def main():
    N, W = list(map(int, input().split()))
    Ws = []
    Vs = []
    for _ in range(N):
        w, v = list(map(int, input().split()))
        Ws.append(w)
        Vs.append(v)
    mv = sum(Vs)
    dp = [[float("INF")] * (mv + 1) for _ in range(N + 1)]
    dp[0][0] = 0
    for i in range(N):
        for j in range(mv + 1):
            if Vs[i] > j:
                dp[i + 1][j] = dp[i][j]
            else:
                dp[i + 1][j] = min(dp[i][j], dp[i][j - Vs[i]] + Ws[i])
    for j in range(mv, -1, -1):
        if W >= dp[N][j]:
            print(j)
            break


main()

def main():
    N, W = list(map(int, input().split()))
    MV = 10**5
    dp = [float("INF")] * (MV + 1)
    dp[0] = 0
    for _ in range(N):
        w, v = list(map(int, input().split()))
        for i in range(MV, -1, -1):
            if v > i:
                tmp = w
            else:
                tmp = dp[i - v] + w
            dp[i] = min(dp[i], tmp)
    ans = 0
    for v, w in enumerate(dp):
        if W >= w:
            ans = max(ans, v)
        else:
            break
    print(ans)


main()

-    Ws = [] -    Vs = [] +    MV = 10**5 +    dp = [float("INF")] * (MV + 1) +    dp[0] = 0 -        Ws.append(w) -        Vs.append(v) -    mv = sum(Vs) -    dp = [[float("INF")] * (mv + 1) for _ in range(N + 1)] -    dp[0][0] = 0 -    for i in range(N): -        for j in range(mv + 1): -            if Vs[i] > j: -                dp[i + 1][j] = dp[i][j] +        for i in range(MV, -1, -1): +            if v > i: +                tmp = w -                dp[i + 1][j] = min(dp[i][j], dp[i][j - Vs[i]] + Ws[i]) -    for j in range(mv, -1, -1): -        if W >= dp[N][j]: -            print(j) +                tmp = dp[i - v] + w +            dp[i] = min(dp[i], tmp) +    ans = 0 +    for v, w in enumerate(dp): +        if W >= w: +            ans = max(ans, v) +        else: +    print(ans)