N, W = [int(i) for i in input().split()]

w, v = [0]*N, [0]*N

 

for i in range(N):

  w[i], v[i] = [int(_) for _ in input().split()]

V = sum(v)



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

# dp[i][j] i番目までの荷物で価値がj以上になるように選んだときの重さの最小値

dp[0][0] = 0

for i in range(N):

  for j in range(V+1):

    if v[i] <= j:# 荷物v[i]の価値がjに足りてないのでi番目の荷物を入れる可能性がある

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

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



ans = 0

for j in range(V + 1):

  if dp[N][j] <= W:

    ans = j    

      

print(ans)
N, W = [int(i) for i in input().split()]

w, v = [0]*N, [0]*N

 

for i in range(N):

  w[i], v[i] = [int(_) for _ in input().split()]

V = sum(v)

 

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

# dp[i][j] i番目までの荷物で価値がj以上になるように選んだときの重さの最小値

dp[0][0] = 0

for i in range(N):

  for j in range(V+1):

    if v[i] <= j:# 荷物v[i]の価値がjに足りてないのでi番目の荷物を入れる可能性がある

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

    else:      

      dp[i+1][j] = dp[i][j]

 

ans = 0

for j in range(V + 1):

  if dp[N][j] <= W:

    ans = j    

      

print(ans)

N, W = [int(i) for i in input().split()]
w, v = [0] * N, [0] * N
for i in range(N):
    w[i], v[i] = [int(_) for _ in input().split()]
V = sum(v)
dp = [[float("inf")] * (V + 1) for _ in range(N + 1)]
# dp[i][j] i番目までの荷物で価値がj以上になるように選んだときの重さの最小値
dp[0][0] = 0
for i in range(N):
    for j in range(V + 1):
        if v[i] <= j:  # 荷物v[i]の価値がjに足りてないのでi番目の荷物を入れる可能性がある
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i])
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
ans = 0
for j in range(V + 1):
    if dp[N][j] <= W:
        ans = j
print(ans)

N, W = [int(i) for i in input().split()]
w, v = [0] * N, [0] * N
for i in range(N):
    w[i], v[i] = [int(_) for _ in input().split()]
V = sum(v)
dp = [[float("inf")] * (V + 1) for _ in range(N + 1)]
# dp[i][j] i番目までの荷物で価値がj以上になるように選んだときの重さの最小値
dp[0][0] = 0
for i in range(N):
    for j in range(V + 1):
        if v[i] <= j:  # 荷物v[i]の価値がjに足りてないのでi番目の荷物を入れる可能性がある
            dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i])
        else:
            dp[i + 1][j] = dp[i][j]
ans = 0
for j in range(V + 1):
    if dp[N][j] <= W:
        ans = j
print(ans)

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