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

w=[]

v=[]

for i in range(n):

  a,b=list(map(int,input().split()))

  w.append(a)

  v.append(b)

V=sum(v)

INF=10**18

dp=[[INF for _ in range(V+1)] for _ in range(n+1)]

dp[0][0]=0

for i in range(n):

  for j in range(V+1):

    if j<v[i]:dp[i+1][j]=dp[i][j]

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

for i in range(V+1):

  if dp[n][i]<=W:ans=i

print(ans)
INF=10**18

n,m=list(map(int,input().split()))

w=[0]*n

v=[0]*n

for i in range(n):

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

k=sum(v)

dp=[INF]*(k+1)

dp[0]=0

for i in range(n):

  for j in range(k,-1,-1):

    if j>=v[i] and dp[j-v[i]]!=INF:dp[j]=min(dp[j],dp[j-v[i]]+w[i])

for i,x in enumerate(dp):

  if x<=m:ans=i

print(ans)
n, W = list(map(int, input().split()))
w = []
v = []
for i in range(n):
    a, b = list(map(int, input().split()))
    w.append(a)
    v.append(b)
V = sum(v)
INF = 10**18
dp = [[INF for _ in range(V + 1)] for _ in range(n + 1)]
dp[0][0] = 0
for i in range(n):
    for j in range(V + 1):
        if j < v[i]:
            dp[i + 1][j] = dp[i][j]
        else:
            dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i])
for i in range(V + 1):
    if dp[n][i] <= W:
        ans = i
print(ans)

INF = 10**18
n, m = list(map(int, input().split()))
w = [0] * n
v = [0] * n
for i in range(n):
    w[i], v[i] = list(map(int, input().split()))
k = sum(v)
dp = [INF] * (k + 1)
dp[0] = 0
for i in range(n):
    for j in range(k, -1, -1):
        if j >= v[i] and dp[j - v[i]] != INF:
            dp[j] = min(dp[j], dp[j - v[i]] + w[i])
for i, x in enumerate(dp):
    if x <= m:
        ans = i
print(ans)

-n, W = list(map(int, input().split())) -w = [] -v = [] +INF = 10**18 +n, m = list(map(int, input().split())) +w = [0] * n +v = [0] * n -    a, b = list(map(int, input().split())) -    w.append(a) -    v.append(b) -V = sum(v) -INF = 10**18 -dp = [[INF for _ in range(V + 1)] for _ in range(n + 1)] -dp[0][0] = 0 +    w[i], v[i] = list(map(int, input().split())) +k = sum(v) +dp = [INF] * (k + 1) +dp[0] = 0 -    for j in range(V + 1): -        if j < v[i]: -            dp[i + 1][j] = dp[i][j] -        else: -            dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]) -for i in range(V + 1): -    if dp[n][i] <= W: +    for j in range(k, -1, -1): +        if j >= v[i] and dp[j - v[i]] != INF: +            dp[j] = min(dp[j], dp[j - v[i]] + w[i]) +for i, x in enumerate(dp): +    if x <= m: