def kp(vv, wv, w)
	dp1 = Array.new(w + 1, 0)
	vv.length.times do |i|
		dp2 = dp1.clone
		(w + 1).times do |j|
			if j < wv[i] || dp2[j] > dp2[j - wv[i]] + vv[i]
				dp1[j] = dp2[j]
			else
				dp1[j] = dp2[j - wv[i]] + vv[i]
			end
		end
	end
	return dp1[w]
end

if __FILE__ == $0
	vv = Array.new(0)
	wv = Array.new(0)
	n, w = gets.split.map(&:to_i)
	n.times do
		vi, wi = gets.split.map(&:to_i)
		vv << vi
		wv << wi
	end
	puts("#{kp(vv, wv, w)}")
end

