def main():

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

    #dp[v] vとなる最小のＷ

    dp = [10**9+1 for _ in range(10**5+1)]

    for _ in range(N):

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

        for val in range(10**5, 1, -1):

            if val - v < 1:

                break

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

        if dp[v] > w:

            dp[v] = w

    ans = 0

    for v, w in enumerate(dp):

        if w <= W:

            ans = max(ans, v)

    print(ans)

if __name__ == '__main__':

    main()
import numpy as np

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

dp = np.ones(10**5+1, dtype=np.int64) * np.inf

dp[0] = 0

for _ in range(N):

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

    np.minimum(dp[v:], dp[:-v] + w , dp[v:])

print((max(np.where(dp <= W)[0])))
def main():
    N, W = list(map(int, input().split()))
    # dp[v] vとなる最小のＷ
    dp = [10**9 + 1 for _ in range(10**5 + 1)]
    for _ in range(N):
        w, v = list(map(int, input().split()))
        for val in range(10**5, 1, -1):
            if val - v < 1:
                break
            dp[val] = min(dp[val], dp[val - v] + w)
        if dp[v] > w:
            dp[v] = w
    ans = 0
    for v, w in enumerate(dp):
        if w <= W:
            ans = max(ans, v)
    print(ans)


if __name__ == "__main__":
    main()

import numpy as np

N, W = list(map(int, input().split()))
dp = np.ones(10**5 + 1, dtype=np.int64) * np.inf
dp[0] = 0
for _ in range(N):
    w, v = list(map(int, input().split()))
    np.minimum(dp[v:], dp[:-v] + w, dp[v:])
print((max(np.where(dp <= W)[0])))

-def main(): -    N, W = list(map(int, input().split())) -    # dp[v] vとなる最小のＷ -    dp = [10**9 + 1 for _ in range(10**5 + 1)] -    for _ in range(N): -        w, v = list(map(int, input().split())) -        for val in range(10**5, 1, -1): -            if val - v < 1: -                break -            dp[val] = min(dp[val], dp[val - v] + w) -        if dp[v] > w: -            dp[v] = w -    ans = 0 -    for v, w in enumerate(dp): -        if w <= W: -            ans = max(ans, v) -    print(ans) +import numpy as np - -if __name__ == "__main__": -    main() +N, W = list(map(int, input().split())) +dp = np.ones(10**5 + 1, dtype=np.int64) * np.inf +dp[0] = 0 +for _ in range(N): +    w, v = list(map(int, input().split())) +    np.minimum(dp[v:], dp[:-v] + w, dp[v:]) +print((max(np.where(dp <= W)[0])))