def read
  gets.to_i
end

def solve(n)
  r=[ 1, 2, 3, 4, 5, 6, 7, 8].take(n).to_a +
    9.step(Float::INFINITY, 10).take([0, n-8].max).to_a
  r.map{|i| i.to_s.chars.sort.join('')}.uniq.map(&:to_i).sort
end

puts solve(read)
