a, b = gets.split(" ").map(&:to_i) ary = Array.new a.upto(b) do |i| if i % 3 == 0 || i.to_s.split("").any? {|s| s == "3"} puts i end end