import sys



input = sys.stdin.readline





def main():

    N, W = [int(x) for x in input().split()]

    WV = [[int(x) for x in input().split()] for _ in range(N)]



    sumv = 0

    for w, v in WV:

        sumv += v



    dp = [[float("inf")] * (sumv + 1) for j in range(N + 1)]



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

        for j in range(sumv + 1):

            w, v = WV[i - 1]

            if j <= v:

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

            else:

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



    ans = 0

    for i in range(sumv + 1):

        if dp[N][i] > W:

            break

        else:

            ans = i



    print(ans)





if __name__ == '__main__':

    main()

import sys



input = sys.stdin.readline





def main():

    N, W = [int(x) for x in input().split()]

    WV = [[int(x) for x in input().split()] for _ in range(N)]



    sumv = 0

    for w, v in WV:

        sumv += v



    dp = [[10 ** 9 + 1] * (sumv + 1) for j in range(N + 1)]



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

        for j in range(sumv + 1):

            w, v = WV[i - 1]

            if j <= v:

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

            else:

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



    ans = 0

    for i in range(sumv + 1):

        if dp[N][i] > W:

            break

        else:

            ans = i



    print(ans)





if __name__ == '__main__':

    main()

import sys

input = sys.stdin.readline


def main():
    N, W = [int(x) for x in input().split()]
    WV = [[int(x) for x in input().split()] for _ in range(N)]
    sumv = 0
    for w, v in WV:
        sumv += v
    dp = [[float("inf")] * (sumv + 1) for j in range(N + 1)]
    for i in range(1, N + 1):
        for j in range(sumv + 1):
            w, v = WV[i - 1]
            if j <= v:
                dp[i][j] = min(w, dp[i - 1][j])
            else:
                dp[i][j] = min(dp[i - 1][j], w + dp[i - 1][j - v])
    ans = 0
    for i in range(sumv + 1):
        if dp[N][i] > W:
            break
        else:
            ans = i
    print(ans)


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline


def main():
    N, W = [int(x) for x in input().split()]
    WV = [[int(x) for x in input().split()] for _ in range(N)]
    sumv = 0
    for w, v in WV:
        sumv += v
    dp = [[10**9 + 1] * (sumv + 1) for j in range(N + 1)]
    for i in range(1, N + 1):
        for j in range(sumv + 1):
            w, v = WV[i - 1]
            if j <= v:
                dp[i][j] = min(w, dp[i - 1][j])
            else:
                dp[i][j] = min(dp[i - 1][j], w + dp[i - 1][j - v])
    ans = 0
    for i in range(sumv + 1):
        if dp[N][i] > W:
            break
        else:
            ans = i
    print(ans)


if __name__ == "__main__":
    main()

-    dp = [[float("inf")] * (sumv + 1) for j in range(N + 1)] +    dp = [[10**9 + 1] * (sumv + 1) for j in range(N + 1)]