import sys



# input処理を高速化する

input = sys.stdin.readline



# 入力

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

# sum_vの取りうる上限値

MAX_V = (10**3) * N +1

# 最小値を求めるので無限大の値

f_inf = float('inf')



def knapsack(n, w):

    # dpの初期化　dp[sum_v]は重さの総和の最小値

    dp = [f_inf] * MAX_V

    # 初期条件

    dp[0] = 0

    sum_v = 0

    # forは全て関数の中で回す。

    # 入力

    for i in range(N):

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

        for j in range(MAX_V, v-1, -1):

            new_weight = dp[j - v] + w

            if new_weight > W:

                continue

            if dp[j] > new_weight:

                dp[j] = new_weight



    ans = 0

    for sum_v in range(MAX_V):

        if dp[sum_v] <= W:

            ans = sum_v

    print(ans)



knapsack(N, W)

import sys

import numpy as np



# input処理を高速化する

input = sys.stdin.readline



# 入力

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

# sum_vの取りうる上限値

MAX_V = (10**3) * N +1



def knapsack(n, w):

    # dp[i][j] : i番目の品物で価値jの重さの最小値

    dp = np.full([N+1, MAX_V], np.inf)

    dp[0][0] = 0

    for i in range(n):

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

        dp[i+1] = dp[i]

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

    print((np.max(np.where(dp <= W))))



knapsack(N, W)

import sys

# input処理を高速化する
input = sys.stdin.readline
# 入力
N, W = list(map(int, input().split()))
# sum_vの取りうる上限値
MAX_V = (10**3) * N + 1
# 最小値を求めるので無限大の値
f_inf = float("inf")


def knapsack(n, w):
    # dpの初期化　dp[sum_v]は重さの総和の最小値
    dp = [f_inf] * MAX_V
    # 初期条件
    dp[0] = 0
    sum_v = 0
    # forは全て関数の中で回す。
    # 入力
    for i in range(N):
        w, v = list(map(int, input().split()))
        for j in range(MAX_V, v - 1, -1):
            new_weight = dp[j - v] + w
            if new_weight > W:
                continue
            if dp[j] > new_weight:
                dp[j] = new_weight
    ans = 0
    for sum_v in range(MAX_V):
        if dp[sum_v] <= W:
            ans = sum_v
    print(ans)


knapsack(N, W)

import sys
import numpy as np

# input処理を高速化する
input = sys.stdin.readline
# 入力
N, W = list(map(int, input().split()))
# sum_vの取りうる上限値
MAX_V = (10**3) * N + 1


def knapsack(n, w):
    # dp[i][j] : i番目の品物で価値jの重さの最小値
    dp = np.full([N + 1, MAX_V], np.inf)
    dp[0][0] = 0
    for i in range(n):
        w, v = list(map(int, input().split()))
        dp[i + 1] = dp[i]
        dp[i + 1][v:] = np.minimum(dp[i][v:], dp[i][:-v] + w)
    print((np.max(np.where(dp <= W))))


knapsack(N, W)

+import numpy as np -# 最小値を求めるので無限大の値 -f_inf = float("inf") -    # dpの初期化　dp[sum_v]は重さの総和の最小値 -    dp = [f_inf] * MAX_V -    # 初期条件 -    dp[0] = 0 -    sum_v = 0 -    # forは全て関数の中で回す。 -    # 入力 -    for i in range(N): +    # dp[i][j] : i番目の品物で価値jの重さの最小値 +    dp = np.full([N + 1, MAX_V], np.inf) +    dp[0][0] = 0 +    for i in range(n): -        for j in range(MAX_V, v - 1, -1): -            new_weight = dp[j - v] + w -            if new_weight > W: -                continue -            if dp[j] > new_weight: -                dp[j] = new_weight -    ans = 0 -    for sum_v in range(MAX_V): -        if dp[sum_v] <= W: -            ans = sum_v -    print(ans) +        dp[i + 1] = dp[i] +        dp[i + 1][v:] = np.minimum(dp[i][v:], dp[i][:-v] + w) +    print((np.max(np.where(dp <= W))))