a, b = gets.split(' ').map(&:to_i) a.upto(b) do |n| puts n if n % 3 == 0 || n.to_s.include?('3') end