N ,W = gets.split.map{|i| i.to_i}
w = Array.new(N)
v = Array.new(N)
for i in 0 .. N - 1
    w[i] , v[i] = gets.split.map{|i| i.to_i}
end

c = Hash.new
dp = Hash.new(10 ** 18)
dp[0] = 0
max = 0

for i in 0 .. N - 1

    dp.each do |key , value|

        if value + w[i] > W
            next
        end

        if dp[key + v[i]] > value + w[i]
            c[key + v[i]] = value + w[i]

            if key + v[i] > max
                max = key + v[i]
            end

        end

    end

    dp.merge!(c)
    c.clear

end

puts max