def main():

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

    w = [0] * N

    v = [0] * N

    for i in range(N):

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



    max_v = max(v)

    dp = [[float('inf')] * (max_v * N + 5) for _ in range(N + 5)]



    dp[0][0] = 0



    for i in range(N):

        for j in range(max_v * N):

            if j + v[i] <= max_v * N:

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

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



    ans = 0

    for j in range(max_v * N + 1):

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

            ans = j



    print(ans)



if __name__ == "__main__":

    main()
def main():

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

    weight = [0] * N

    value = [0] * N

    for i in range(N):

        weight[i], value[i] = list(map(int, input().split()))

    V = sum(value)

    dp = [[float('inf')] * (V + 5) for _ in range(N + 5)]

    dp[0][0] = 0

    for i in range(N):

        for v in range(V+1):

            if v - value[i] >= 0:

                dp[i+1][v] = min(dp[i][v-value[i]] + weight[i], dp[i][v])

            else:

                dp[i+1][v] = dp[i][v]

    ans = 0

    for v in range(V+1):

        if dp[N][v] <= W:

            ans = v

    print(ans)



if __name__ == "__main__":

    main()
def main():
    N, W = list(map(int, input().split()))
    w = [0] * N
    v = [0] * N
    for i in range(N):
        w[i], v[i] = list(map(int, input().split()))
    max_v = max(v)
    dp = [[float("inf")] * (max_v * N + 5) for _ in range(N + 5)]
    dp[0][0] = 0
    for i in range(N):
        for j in range(max_v * N):
            if j + v[i] <= max_v * N:
                dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i])
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
    ans = 0
    for j in range(max_v * N + 1):
        if dp[N][j] <= W:
            ans = j
    print(ans)


if __name__ == "__main__":
    main()

def main():
    N, W = list(map(int, input().split()))
    weight = [0] * N
    value = [0] * N
    for i in range(N):
        weight[i], value[i] = list(map(int, input().split()))
    V = sum(value)
    dp = [[float("inf")] * (V + 5) for _ in range(N + 5)]
    dp[0][0] = 0
    for i in range(N):
        for v in range(V + 1):
            if v - value[i] >= 0:
                dp[i + 1][v] = min(dp[i][v - value[i]] + weight[i], dp[i][v])
            else:
                dp[i + 1][v] = dp[i][v]
    ans = 0
    for v in range(V + 1):
        if dp[N][v] <= W:
            ans = v
    print(ans)


if __name__ == "__main__":
    main()

-    w = [0] * N -    v = [0] * N +    weight = [0] * N +    value = [0] * N -        w[i], v[i] = list(map(int, input().split())) -    max_v = max(v) -    dp = [[float("inf")] * (max_v * N + 5) for _ in range(N + 5)] +        weight[i], value[i] = list(map(int, input().split())) +    V = sum(value) +    dp = [[float("inf")] * (V + 5) for _ in range(N + 5)] -        for j in range(max_v * N): -            if j + v[i] <= max_v * N: -                dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i]) -            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]) +        for v in range(V + 1): +            if v - value[i] >= 0: +                dp[i + 1][v] = min(dp[i][v - value[i]] + weight[i], dp[i][v]) +            else: +                dp[i + 1][v] = dp[i][v] -    for j in range(max_v * N + 1): -        if dp[N][j] <= W: -            ans = j +    for v in range(V + 1): +        if dp[N][v] <= W: +            ans = v