import sys

n, limit = list(map(int, sys.stdin.readline().split())) 

L = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]



dp = [dict() for i in range(n)]

#print(dp)

dp[0][L[0][1]] = L[0][0]



for i in range(1, n):

    dp[i][L[i][1]] = min(L[i][0], dp[i-1].get(L[i][1], float('inf')))

    for v, w in list(dp[i-1].items()):

        dp[i][v] = min(dp[i-1][v], dp[i].get(v, float('inf')))

        dp[i][L[i][1] + v] = min(L[i][0] + dp[i-1][v], dp[i-1].get(L[i][1] + v, float('inf'))) 

        

ans = 0

for v, w in list(dp[-1].items()):

    if w <=limit:

        if ans < v:

            ans = v

#print(dp)

print(ans)
import sys

from collections import defaultdict

n, limit = list(map(int, sys.stdin.readline().split()))

L = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]



dp =[defaultdict(int) for _ in range(n)]

dp[0][L[0][1]] = L[0][0]

#print(dp)

for i in range(1, n):

    dp[i][L[i][1]] = min(L[i][0], dp[i-1].get(L[i][1], L[i][0])) #①L[i]の荷物を代入

    for v, w in list(dp[i-1].items()):

        dp[i][v] = min(w, dp[i].get(v, w)) #②i-1番目の各荷物を代入

        dp[i][v+L[i][1]] = min(w + L[i][0], dp[i-1].get(v+L[i][1], w + L[i][0]) ) #③i-1番目の各荷物とL[i]を足した物を代入

        #print(dp)



ans =0

for v, w in list(dp[-1].items()):

    if w<=limit:

        if ans < v:

            ans = v



print(ans)
import sys

n, limit = list(map(int, sys.stdin.readline().split()))
L = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
dp = [dict() for i in range(n)]
# print(dp)
dp[0][L[0][1]] = L[0][0]
for i in range(1, n):
    dp[i][L[i][1]] = min(L[i][0], dp[i - 1].get(L[i][1], float("inf")))
    for v, w in list(dp[i - 1].items()):
        dp[i][v] = min(dp[i - 1][v], dp[i].get(v, float("inf")))
        dp[i][L[i][1] + v] = min(
            L[i][0] + dp[i - 1][v], dp[i - 1].get(L[i][1] + v, float("inf"))
        )
ans = 0
for v, w in list(dp[-1].items()):
    if w <= limit:
        if ans < v:
            ans = v
# print(dp)
print(ans)

import sys
from collections import defaultdict

n, limit = list(map(int, sys.stdin.readline().split()))
L = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
dp = [defaultdict(int) for _ in range(n)]
dp[0][L[0][1]] = L[0][0]
# print(dp)
for i in range(1, n):
    dp[i][L[i][1]] = min(L[i][0], dp[i - 1].get(L[i][1], L[i][0]))  # ①L[i]の荷物を代入
    for v, w in list(dp[i - 1].items()):
        dp[i][v] = min(w, dp[i].get(v, w))  # ②i-1番目の各荷物を代入
        dp[i][v + L[i][1]] = min(
            w + L[i][0], dp[i - 1].get(v + L[i][1], w + L[i][0])
        )  # ③i-1番目の各荷物とL[i]を足した物を代入
        # print(dp)
ans = 0
for v, w in list(dp[-1].items()):
    if w <= limit:
        if ans < v:
            ans = v
print(ans)

+from collections import defaultdict -dp = [dict() for i in range(n)] +dp = [defaultdict(int) for _ in range(n)] +dp[0][L[0][1]] = L[0][0] -dp[0][L[0][1]] = L[0][0] -    dp[i][L[i][1]] = min(L[i][0], dp[i - 1].get(L[i][1], float("inf"))) +    dp[i][L[i][1]] = min(L[i][0], dp[i - 1].get(L[i][1], L[i][0]))  # ①L[i]の荷物を代入 -        dp[i][v] = min(dp[i - 1][v], dp[i].get(v, float("inf"))) -        dp[i][L[i][1] + v] = min( -            L[i][0] + dp[i - 1][v], dp[i - 1].get(L[i][1] + v, float("inf")) -        ) +        dp[i][v] = min(w, dp[i].get(v, w))  # ②i-1番目の各荷物を代入 +        dp[i][v + L[i][1]] = min( +            w + L[i][0], dp[i - 1].get(v + L[i][1], w + L[i][0]) +        )  # ③i-1番目の各荷物とL[i]を足した物を代入 +        # print(dp) -# print(dp)