Problem:
Score : 100 points

Problem Statement

There are N items, numbered 1, 2, \ldots, N.
For each i (1 \leq i \leq N), Item i has a weight of w_i and a value of v_i.

Taro has decided to choose some of the N items and carry them home in a knapsack.
The capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W.

Find the maximum possible sum of the values of items that Taro takes home.

Constraints

All values in input are integers.

1 \leq N \leq 100

1 \leq W \leq 10^9

1 \leq w_i \leq W

1 \leq v_i \leq 10^3

Input

Input is given from Standard Input in the following format:

N W
w_1 v_1
w_2 v_2
:
w_N v_N

Output

Print the maximum possible sum of the values of items that Taro takes home.

Sample Input 1

3 8
3 30
4 50
5 60

Sample Output 1

90

Items 1 and 3 should be taken.
Then, the sum of the weights is 3 + 5 = 8, and the sum of the values is 30 + 60 = 90.

Sample Input 2

1 1000000000
1000000000 10

Sample Output 2

10

Sample Input 3

6 15
6 5
5 6
6 4
6 6
3 5
7 2

Sample Output 3

17

Items 2, 4 and 5 should be taken.
Then, the sum of the weights is 5 + 6 + 3 = 14, and the sum of the values is 6 + 6 + 5 = 17.

Solution in PyPy3 (2.4.0) (judge verdict: Time Limit Exceeded)

# -*- coding:utf-8 -*-
"""解説
https://qiita.com/drken/items/dc53c683d6de8aeacf5a#e-%E5%95%8F%E9%A1%8C---knapsack-2

・まず制約を見る
Wの最大値が10**9なので、dp[i][w] みたいにすると、間に合わない

N=100, viの最大値が10**3 なので、N+max(vi) = 10**5 なので、viを使うといけそう

dp[i][v] := i番目までを選んだ時の、価値がv以上のときの、重さの総和の最小値


・DPテーブル
      i   =   0      1      2      3      4      5
例: (w,v) = (2,3), (1,2), (3,6), (2,1), (1,3), (5,85)

i/v | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ...
----------------------------------------------------------------------
0   | 0 | 2 | 2 | 2 | ∞ | ∞ | ∞ | ∞ | ∞ | ∞ | ∞  | ∞  | ∞  | ∞  | ... 
1   | 0 | 1 | 1 | 2 | 3 | 3 | ∞ | ∞ | ∞ | ∞ | ∞  | ∞  | ∞  | ∞  | ...
2   | 0 | 1 | 1 | 2 | 3 | 3 | 3 | 4 | 4 | 5 | 6  | 6  | ∞  | ∞  | ...
3   |
4   |
5   |

     i    =    0        1        2        3
例: (w,v) = (1,100), (1,100), (1,100), (1,100)

i/v | 0 | 1 |...|100|101|...|200|201|...|300|301|...|400|401|...|500|501|...
----------------------------------------------------------------------------
0   | 0 | 1 | 1 | 1 | ∞ | ∞ | ∞ | ∞ | ∞ | ∞ | ∞ | ∞ | ∞ | ∞ | ∞ | ∞ | ∞ | ∞ 
1   | 0 | 1 | 1 | 1 | 2 | 2 | 2 | ∞ | ∞ | ∞ | ∞ | ∞ | ∞ | ∞ | ∞ | ∞ | ∞ | ∞
2   | 0 | 1 | 1 | 1 | 2 | 2 | 2 | 3 | 3 | 3 | ∞ | ∞ | ∞ | ∞ | ∞ | ∞ | ∞ | ∞
3   | 0 | 1 | 1 | 1 | 2 | 2 | 2 | 3 | 3 | 3 | 4 | 4 | 4 | ∞ | ∞ | ∞ | ∞ | ∞

"""

def solve():
    N, W = list(map(int, input().split()))
    Ws, Vs = [], []
    for i in range(N):
        w, v = list(map(int, input().split()))
        Ws.append(w)
        Vs.append(v)
    M = (10**3) * N
    
    # dp[i][v] := i番目までを選んだ時の、価値がv以上のときの、重さの総和の最小値
    dp = [[float("inf") for _ in range(0, M+1)] for __ in range(0, N)]

    # 初期値
    for i in range(0, N):
        dp[i][0] = 0 # 価値0の重さの最小値は0
    
    for v in range(1, M+1):
        if v <= Vs[0]:
            dp[0][v] = Ws[0]
    
    # dpを埋める
    for i in range(1, N):
        for v in range(0, M+1):
            
            if v-Vs[i] >= 0:
                dp[i][v] = min(dp[i-1][v], dp[i-1][v-Vs[i]]+Ws[i])
            else:
                dp[i][v] = min(dp[i-1][v], Ws[i])
            
            """
            if v-Vs[i] >= 0:
                dp[i][v] = min(dp[i][v], dp[i-1][v-Vs[i]]+Ws[i])  # 選んだとき
            dp[i][v] = min(dp[i][v], dp[i-1][v])
            """

    # 答えを出す
    for v in range(M, -1, -1):
        if dp[N-1][v] <= W:
            ans = v
            break
    """
    for v in range(0, 10**5+1):
        if dp[N-1][v] <= W:
            ans = v
    """
    print(ans)


if __name__ == "__main__":
    solve()