f0=[3,5,17,257,65537] f =[] a =[] (1..f0.size).each do |l| f0.combination(l) do |a| f << a.reduce(:*) end end f.unshift(1) n=gets.to_i while f[0] <= n a+=f f.map!{|e|e*2} end p a.uniq.sort.count{|x| 3 <= x && x <= n}