import sys

input = sys.stdin.readline



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

table = []

for i in range(N):

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

  table.append((w,v))

INF = W+1

dp = [[INF]*(10**3*N+1) for i in range(N+1)]

dp[0][0] = 0

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

  for k in range(10**3*N+1):

    w,v = table[i-1]

    dp[i][k] = dp[i-1][k]

    if v<=k and dp[i-1][k-v] <= INF:

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



for i in range(10**3*N,-1,-1):

  if 0<= dp[-1][i] <= W:

    print(i)

    exit()

import sys

input = sys.stdin.readline



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

table = []

for i in range(N):

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

  table.append((w,v))

dp = [[W+1]*(10**3*N+1) for i in range(N+1)]

dp[0][0] = 0



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

  w,v = table[i-1]

  for j in range(10**3*N+1):

    dp[i][j] = dp[i-1][j]

    if j>=v:

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



for i in range(10**3*N,-1,-1):

  if dp[-1][i] <= W:

    print(i)

    exit()
import sys

input = sys.stdin.readline
N, W = list(map(int, input().split()))
table = []
for i in range(N):
    w, v = list(map(int, input().split()))
    table.append((w, v))
INF = W + 1
dp = [[INF] * (10**3 * N + 1) for i in range(N + 1)]
dp[0][0] = 0
for i in range(1, N + 1):
    for k in range(10**3 * N + 1):
        w, v = table[i - 1]
        dp[i][k] = dp[i - 1][k]
        if v <= k and dp[i - 1][k - v] <= INF:
            dp[i][k] = min(dp[i][k], dp[i - 1][k - v] + w)
for i in range(10**3 * N, -1, -1):
    if 0 <= dp[-1][i] <= W:
        print(i)
        exit()

import sys

input = sys.stdin.readline
N, W = list(map(int, input().split()))
table = []
for i in range(N):
    w, v = list(map(int, input().split()))
    table.append((w, v))
dp = [[W + 1] * (10**3 * N + 1) for i in range(N + 1)]
dp[0][0] = 0
for i in range(1, N + 1):
    w, v = table[i - 1]
    for j in range(10**3 * N + 1):
        dp[i][j] = dp[i - 1][j]
        if j >= v:
            dp[i][j] = min(dp[i][j], dp[i - 1][j - v] + w)
for i in range(10**3 * N, -1, -1):
    if dp[-1][i] <= W:
        print(i)
        exit()

-INF = W + 1 -dp = [[INF] * (10**3 * N + 1) for i in range(N + 1)] +dp = [[W + 1] * (10**3 * N + 1) for i in range(N + 1)] -    for k in range(10**3 * N + 1): -        w, v = table[i - 1] -        dp[i][k] = dp[i - 1][k] -        if v <= k and dp[i - 1][k - v] <= INF: -            dp[i][k] = min(dp[i][k], dp[i - 1][k - v] + w) +    w, v = table[i - 1] +    for j in range(10**3 * N + 1): +        dp[i][j] = dp[i - 1][j] +        if j >= v: +            dp[i][j] = min(dp[i][j], dp[i - 1][j - v] + w) -    if 0 <= dp[-1][i] <= W: +    if dp[-1][i] <= W: