class Calc0207 def initialize(args) args = args.map { |l| l.chomp.split(/\s+/) } @a, @b = args.shift.map(&:to_i) end def run (@a..@b).select { |n| n % 3 == 0 || n.to_s.include?('3') } end end puts Calc0207.new(STDIN.readlines).run if __FILE__ == $0