import sys

import numpy as np

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

it = iter(map(int, sys.stdin.read().split()))

dp = np.full(N * 1000 + 1, 10 ** 10, dtype=np.int64)

dp[0] = 0

for w, v in zip(it, it):

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

print((((dp <= W) * np.arange(N * 1000 + 1)).max()))
import sys

import numpy as np

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

it = iter(map(int, sys.stdin.read().split()))

dp = np.full(N * 1000 + 1, W + 1, dtype=np.int64)

dp[0] = 0

for w, v in zip(it, it):

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

print((((dp <= W) * np.arange(N * 1000 + 1)).max()))
import sys
import numpy as np

N, W = list(map(int, input().split()))
it = iter(map(int, sys.stdin.read().split()))
dp = np.full(N * 1000 + 1, 10**10, dtype=np.int64)
dp[0] = 0
for w, v in zip(it, it):
    np.minimum(dp[:-v] + w, dp[v:], out=dp[v:])
print((((dp <= W) * np.arange(N * 1000 + 1)).max()))

import sys
import numpy as np

N, W = list(map(int, input().split()))
it = iter(map(int, sys.stdin.read().split()))
dp = np.full(N * 1000 + 1, W + 1, dtype=np.int64)
dp[0] = 0
for w, v in zip(it, it):
    np.minimum(dp[:-v] + w, dp[v:], out=dp[v:])
print((((dp <= W) * np.arange(N * 1000 + 1)).max()))

-dp = np.full(N * 1000 + 1, 10**10, dtype=np.int64) +dp = np.full(N * 1000 + 1, W + 1, dtype=np.int64)