fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(java.util.Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun next(a0: IntArray): IntArray {
        var a = a0
        var i = 0
        while (a[i] == 9 || (i + 1 < a.count() && a[i] + 1 > a[i + 1] + 1)) {
            i++
            if (a0.count() <= i) {
                a = a0 + 0
                break
            }
        }
        a[i]++
        i--
        while (i >= 0) {
            a[i] = listOf(a[i + 1] - 1, 0).max()!!
            i--
        }
        return a
    }

    fun solve(sc: java.util.Scanner, pw: java.io.PrintWriter) {
        val K = sc.next().toInt()
        var n = IntArray(1) { 0 }
        for (i in 0 until K) {
            n = next(n)
//            println(n.reversed().joinToString(""))
        }
        pw.println(n.reversed().joinToString(""))
    }
}
