a = gets.chomp!.split(' ').map(&:to_i) b = (a[0]..a[1]).select do |x| if x % 3 == 0 x elsif x.to_s.chars.find { |n| n == '3' } x end end puts b