# 入力された値を文字列で受け取る input = gets.chomp xmin, xmax = input.split a = xmin.to_i b = xmax.to_i c = b - a c.times do |i| if (i + a) % 3 == 0 puts i + a elsif (i + a).to_s.include?("3") puts i + a end end