import itertools,sys

def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

N,W = LI()

wv = [LI() for _ in range(N)]

V = 10**5

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

dp[0][0] = 0

for i,j in itertools.product(list(range(1,N+1)),list(range(V+1))):

    w,v = wv[i-1]

    if j-v>=0 and dp[i-1][j-v]+w<=W:

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

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

print((max([i for i in range(V+1) if dp[-1][i]<=W])))

import sys

def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

N,W = LI()

wv = [LI() for _ in range(N)]

V = N*10**3

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

dp[0][0] = 0

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

    w,v = wv[i-1]

    for j in range(V+1):

        if j-v>=0 and dp[i-1][j-v]+w<=W:

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

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

print((max([i for i in range(V+1) if dp[-1][i]<=W])))

import itertools, sys


def LI():
    return list(map(int, sys.stdin.readline().rstrip().split()))


N, W = LI()
wv = [LI() for _ in range(N)]
V = 10**5
dp = [[float("INF")] * (V + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i, j in itertools.product(list(range(1, N + 1)), list(range(V + 1))):
    w, v = wv[i - 1]
    if j - v >= 0 and dp[i - 1][j - v] + w <= W:
        dp[i][j] = min(dp[i][j], dp[i - 1][j - v] + w)
    dp[i][j] = min(dp[i][j], dp[i - 1][j])
print((max([i for i in range(V + 1) if dp[-1][i] <= W])))

import sys


def LI():
    return list(map(int, sys.stdin.readline().rstrip().split()))


N, W = LI()
wv = [LI() for _ in range(N)]
V = N * 10**3
dp = [[float("INF")] * (V + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(1, N + 1):
    w, v = wv[i - 1]
    for j in range(V + 1):
        if j - v >= 0 and dp[i - 1][j - v] + w <= W:
            dp[i][j] = min(dp[i][j], dp[i - 1][j - v] + w)
        dp[i][j] = min(dp[i][j], dp[i - 1][j])
print((max([i for i in range(V + 1) if dp[-1][i] <= W])))

-import itertools, sys +import sys -V = 10**5 +V = N * 10**3 -for i, j in itertools.product(list(range(1, N + 1)), list(range(V + 1))): +for i in range(1, N + 1): -    if j - v >= 0 and dp[i - 1][j - v] + w <= W: -        dp[i][j] = min(dp[i][j], dp[i - 1][j - v] + w) -    dp[i][j] = min(dp[i][j], dp[i - 1][j]) +    for j in range(V + 1): +        if j - v >= 0 and dp[i - 1][j - v] + w <= W: +            dp[i][j] = min(dp[i][j], dp[i - 1][j - v] + w) +        dp[i][j] = min(dp[i][j], dp[i - 1][j])