a, b = gets.chomp.split(" ").map(&:to_i) res = [] (a..b).each do |i| if i % 3 == 0 then res << i elsif i.to_s.include?("3") then res << i end end puts res