object Main {
  import scala.io.StdIn._
  import scala.annotation.tailrec
  import scala.collection.mutable.Queue
  def main(args: Array[String]): Unit = {
    var lunlunQueue = Queue((1 to 9).map(_.toString):_*)
    var k = readLine().toInt
    @tailrec
    def loop(i: Int): Unit =
      if (i == 1) println(lunlunQueue.head)
      else {
        val h = lunlunQueue.dequeue()
        val l = Character.digit(h.last, 10)
        for {
          i <- Seq(l - 1, l, l + 1)
          if i >= 0 && i < 10
        } {
          lunlunQueue.enqueue(h + (i))
        }
        loop(i - 1)
      }
    loop(k)
  }
}
