a, b = gets.split(" ").map(&:to_i) a.upto(b) do |i| puts i if i.modulo(3).zero? || i.to_s.chars.include?("3") end