import java.util.*

fun main(args: Array<String>) = yorukatsu16d()

fun yorukatsu16d() {
    val k = readLine()!!.toInt()

    val queue = ArrayDeque((1..9L).toList())

    var curr = 1L

    repeat(k) {
        curr = queue.poll()
        val min = Math.max(curr % 10 - 1, 0)
        val max = Math.min(curr % 10 + 1, 9)
        (min..max).map { curr * 10 + it }.let { queue.addAll(it) }
    }

    val answer = curr

    println(answer)
}
