def ascan; gets.split.map(&:to_i);end n, k = ascan aa = (1..n).map{gets.to_i} ans = 0 (1..n).each do |m| aa.combination(m) do |cb| w = cb.reduce(:+) ans = [w,ans].max if w <= k end end p ans