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

li=[list(map(int,input().split())) for i in range(N)]

max_n=0

for a in range(N):

    max_n+=li[a][1]

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

dp[0][0]=0

for i in range(N):

    for sum_v in range(max_n+1):

        if sum_v >= li[i][1]:

            dp[i+1][sum_v]=min(dp[i][sum_v],dp[i][sum_v-li[i][1]]+li[i][0])

        else:

            dp[i+1][sum_v]=dp[i][sum_v]

ans=0

for i in range(max_n+1):

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

        ans = i

print(ans)

import sys

sys.setrecursionlimit(10**9)

INF=10**18

MOD=10**9+7

def input(): return sys.stdin.readline().rstrip()



def main():

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

    w,v=[0]*N,[0]*N

    for i in range(N):

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

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

    dp[0][0]=0

    ans=0

    for i in range(N):

        for value in range(10**5+1):

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

            if value>=v[i]:

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

            if dp[i+1][value]<=W:

                ans=max(ans,value)

    print(ans)



if __name__ == '__main__':

    main()

N, W = list(map(int, input().split()))
li = [list(map(int, input().split())) for i in range(N)]
max_n = 0
for a in range(N):
    max_n += li[a][1]
dp = [[float("INF")] * (max_n + 1) for i in range(N + 1)]
dp[0][0] = 0
for i in range(N):
    for sum_v in range(max_n + 1):
        if sum_v >= li[i][1]:
            dp[i + 1][sum_v] = min(dp[i][sum_v], dp[i][sum_v - li[i][1]] + li[i][0])
        else:
            dp[i + 1][sum_v] = dp[i][sum_v]
ans = 0
for i in range(max_n + 1):
    if dp[N][i] <= W:
        ans = i
print(ans)

import sys

sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7


def input():
    return sys.stdin.readline().rstrip()


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


if __name__ == "__main__":
    main()

-N, W = list(map(int, input().split())) -li = [list(map(int, input().split())) for i in range(N)] -max_n = 0 -for a in range(N): -    max_n += li[a][1] -dp = [[float("INF")] * (max_n + 1) for i in range(N + 1)] -dp[0][0] = 0 -for i in range(N): -    for sum_v in range(max_n + 1): -        if sum_v >= li[i][1]: -            dp[i + 1][sum_v] = min(dp[i][sum_v], dp[i][sum_v - li[i][1]] + li[i][0]) -        else: -            dp[i + 1][sum_v] = dp[i][sum_v] -ans = 0 -for i in range(max_n + 1): -    if dp[N][i] <= W: -        ans = i -print(ans) +import sys + +sys.setrecursionlimit(10**9) +INF = 10**18 +MOD = 10**9 + 7 + + +def input(): +    return sys.stdin.readline().rstrip() + + +def main(): +    N, W = list(map(int, input().split())) +    w, v = [0] * N, [0] * N +    for i in range(N): +        w[i], v[i] = list(map(int, input().split())) +    dp = [[INF] * (10**5 + 1) for _ in range(N + 1)] +    dp[0][0] = 0 +    ans = 0 +    for i in range(N): +        for value in range(10**5 + 1): +            dp[i + 1][value] = min(dp[i + 1][value], dp[i][value]) +            if value >= v[i]: +                dp[i + 1][value] = min(dp[i + 1][value], dp[i][value - v[i]] + w[i]) +            if dp[i + 1][value] <= W: +                ans = max(ans, value) +    print(ans) + + +if __name__ == "__main__": +    main()