inf = float('inf')



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

e = tuple(list(map(int, input().split())) for _ in range(n))

wt, vt = list(zip(*e))

sv = sum(vt)



dp = tuple([inf] * (sv + 1) for _ in range(n + 1))

dp[0][0] = 0



for i in range(n):

    dp[i + 1][:vt[i]] = dp[i][:vt[i]]

    for j in range(vt[i], sv + 1):

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



res = -1

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

    if dp[n][j] <= w:

        res = j

        break

print(res)

def main():

    import sys

    readline = sys.stdin.readline



    maxw = 10 ** 11  # 重さの最小化なので、初期値は最大重さとすることにdebugで気づいた

    maxv = 10 ** 5



    n, w = list(map(int, readline().split()))



    dp = [[maxw] * (maxv + 1) for _ in range(n + 1)]

    dp[0][0] = 0



    for i in range(1, n + 1):  # i個目の品物を選ぶかどうか決めた後の重さの総和の最小値,1-indexed

        wi, vi = list(map(int, readline().split()))

        for j in range(vi):

            dp[i][j] = dp[i - 1][j]

        for j in range(vi, maxv + 1):

            dp[i][j] = min(

                dp[i - 1][j],

                dp[i - 1][j - vi] + wi

            )



    ret = next(j for j in reversed(list(range(maxv + 1))) if dp[n][j] <= w)



    print(ret)





if __name__ == '__main__':

    main()

inf = float("inf")
n, w = list(map(int, input().split()))
e = tuple(list(map(int, input().split())) for _ in range(n))
wt, vt = list(zip(*e))
sv = sum(vt)
dp = tuple([inf] * (sv + 1) for _ in range(n + 1))
dp[0][0] = 0
for i in range(n):
    dp[i + 1][: vt[i]] = dp[i][: vt[i]]
    for j in range(vt[i], sv + 1):
        dp[i + 1][j] = min(dp[i][j], dp[i][j - vt[i]] + wt[i])
res = -1
for j in range(sv, -1, -1):
    if dp[n][j] <= w:
        res = j
        break
print(res)

def main():
    import sys

    readline = sys.stdin.readline
    maxw = 10**11  # 重さの最小化なので、初期値は最大重さとすることにdebugで気づいた
    maxv = 10**5
    n, w = list(map(int, readline().split()))
    dp = [[maxw] * (maxv + 1) for _ in range(n + 1)]
    dp[0][0] = 0
    for i in range(1, n + 1):  # i個目の品物を選ぶかどうか決めた後の重さの総和の最小値,1-indexed
        wi, vi = list(map(int, readline().split()))
        for j in range(vi):
            dp[i][j] = dp[i - 1][j]
        for j in range(vi, maxv + 1):
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - vi] + wi)
    ret = next(j for j in reversed(list(range(maxv + 1))) if dp[n][j] <= w)
    print(ret)


if __name__ == "__main__":
    main()

-inf = float("inf") -n, w = list(map(int, input().split())) -e = tuple(list(map(int, input().split())) for _ in range(n)) -wt, vt = list(zip(*e)) -sv = sum(vt) -dp = tuple([inf] * (sv + 1) for _ in range(n + 1)) -dp[0][0] = 0 -for i in range(n): -    dp[i + 1][: vt[i]] = dp[i][: vt[i]] -    for j in range(vt[i], sv + 1): -        dp[i + 1][j] = min(dp[i][j], dp[i][j - vt[i]] + wt[i]) -res = -1 -for j in range(sv, -1, -1): -    if dp[n][j] <= w: -        res = j -        break -print(res) +def main(): +    import sys + +    readline = sys.stdin.readline +    maxw = 10**11  # 重さの最小化なので、初期値は最大重さとすることにdebugで気づいた +    maxv = 10**5 +    n, w = list(map(int, readline().split())) +    dp = [[maxw] * (maxv + 1) for _ in range(n + 1)] +    dp[0][0] = 0 +    for i in range(1, n + 1):  # i個目の品物を選ぶかどうか決めた後の重さの総和の最小値,1-indexed +        wi, vi = list(map(int, readline().split())) +        for j in range(vi): +            dp[i][j] = dp[i - 1][j] +        for j in range(vi, maxv + 1): +            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - vi] + wi) +    ret = next(j for j in reversed(list(range(maxv + 1))) if dp[n][j] <= w) +    print(ret) + + +if __name__ == "__main__": +    main()