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



import numpy as np

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

dp[0] = 0





for _ in range(N):

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

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



print((np.max(np.where(dp<=W))))
import numpy as np

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



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

dp[0] = 0



for _ in range(N):

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

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

  

print((np.max(np.where(dp<=W))))
N, W = list(map(int, input().split()))
import numpy as np

dp = np.full(N * 1000 + 1, W + 1, dtype=int)
dp[0] = 0
for _ in range(N):
    w, v = list(map(int, input().split()))
    dp[v:] = np.minimum(dp[v:], dp[:-v] + w)
print((np.max(np.where(dp <= W))))

import numpy as np

N, W = list(map(int, input().split()))
dp = np.full(N * 1000 + 1, W + 1, dtype=int)
dp[0] = 0
for _ in range(N):
    w, v = list(map(int, input().split()))
    dp[v:] = np.minimum(dp[v:], dp[:-v] + w)
print((np.max(np.where(dp <= W))))

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