a, b = gets.split.map(&:to_i) a.upto(b) { |i| puts i if i % 3 == 0 || i.digits.member?(3) }