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

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



INF = 10**9+1000

SUM_V = sum([A[1] for A in WV])

dp = [[INF]*(SUM_V+1) for i in range(N+1)]

dp[0][0] = 0

for i in range(N+1):

    dp[i][0] = 0



for n in range(0, N):

    for v in range(0, SUM_V+1):

        if v >= WV[n][1]:

            dp[n+1][v] = min(dp[n][v-WV[n][1]] + WV[n][0], dp[n][v])

        else:

            dp[n+1][v] = dp[n][v]



for n in range(0, N+1):

    for v in range(0, SUM_V+1):

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

            dp[n][v] = -1



print((max([max([i for i,v in enumerate(dd) if v == -1]) for dd in dp])))
import bisect



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

w = [0] * (N + 1)

v = [0] * (N + 1)



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

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

INF = 1000000010

MAX_V = 100010

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

dp[0][0] = 0



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

    for value in range(MAX_V):

        if value <= v[i]:

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

        else:

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



print((bisect.bisect_right(dp[N], W)-1))
N, W = list(map(int, input().split()))
WV = [list(map(int, input().split())) for i in range(N)]
INF = 10**9 + 1000
SUM_V = sum([A[1] for A in WV])
dp = [[INF] * (SUM_V + 1) for i in range(N + 1)]
dp[0][0] = 0
for i in range(N + 1):
    dp[i][0] = 0
for n in range(0, N):
    for v in range(0, SUM_V + 1):
        if v >= WV[n][1]:
            dp[n + 1][v] = min(dp[n][v - WV[n][1]] + WV[n][0], dp[n][v])
        else:
            dp[n + 1][v] = dp[n][v]
for n in range(0, N + 1):
    for v in range(0, SUM_V + 1):
        if dp[n][v] <= W:
            dp[n][v] = -1
print((max([max([i for i, v in enumerate(dd) if v == -1]) for dd in dp])))

import bisect

N, W = list(map(int, input().split()))
w = [0] * (N + 1)
v = [0] * (N + 1)
for i in range(1, N + 1):
    w[i], v[i] = list(map(int, input().split()))
INF = 1000000010
MAX_V = 100010
dp = [[INF] * MAX_V for _ in range(N + 1)]
dp[0][0] = 0
for i in range(1, N + 1):
    for value in range(MAX_V):
        if value <= v[i]:
            dp[i][value] = min(dp[i - 1][value], w[i])
        else:
            dp[i][value] = min(dp[i - 1][value], dp[i - 1][value - v[i]] + w[i])
print((bisect.bisect_right(dp[N], W) - 1))

+import bisect + -WV = [list(map(int, input().split())) for i in range(N)] -INF = 10**9 + 1000 -SUM_V = sum([A[1] for A in WV]) -dp = [[INF] * (SUM_V + 1) for i in range(N + 1)] +w = [0] * (N + 1) +v = [0] * (N + 1) +for i in range(1, N + 1): +    w[i], v[i] = list(map(int, input().split())) +INF = 1000000010 +MAX_V = 100010 +dp = [[INF] * MAX_V for _ in range(N + 1)] -for i in range(N + 1): -    dp[i][0] = 0 -for n in range(0, N): -    for v in range(0, SUM_V + 1): -        if v >= WV[n][1]: -            dp[n + 1][v] = min(dp[n][v - WV[n][1]] + WV[n][0], dp[n][v]) +for i in range(1, N + 1): +    for value in range(MAX_V): +        if value <= v[i]: +            dp[i][value] = min(dp[i - 1][value], w[i]) -            dp[n + 1][v] = dp[n][v] -for n in range(0, N + 1): -    for v in range(0, SUM_V + 1): -        if dp[n][v] <= W: -            dp[n][v] = -1 -print((max([max([i for i, v in enumerate(dd) if v == -1]) for dd in dp]))) +            dp[i][value] = min(dp[i - 1][value], dp[i - 1][value - v[i]] + w[i]) +print((bisect.bisect_right(dp[N], W) - 1))