#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn runrun(n: i64) -> bool {
    let mut n = n;
    let mut last = n % 10;
    n /= 10;
    while n > 0 {
        if ((n % 10) - last).abs() <= 1 {
            last = n % 10;
            n /= 10;
        } else {
            return false
        }
    }
    true
}

fn inc(x: &mut Vec<(usize, i32)>) {
    let n = x.len();
    if (0..n).all(|i| x[i].0 == 9) {
        x.push((0, 0));
        x[0] = (1, 0);
        x[1] = (0, -1);
        for i in 2..n + 1 {
            x[i] = (0, 0);
        }
        return;
    }
    if n == 1 {
        x[0].0 += 1;
        return;
    }
    {
        let mut k = n - 1;
        while k > 0 && (x[k].1 == 1 || x[k].0 == 9) { k -= 1 }
        x[k].0 += 1;
        x[k].1 += 1;
        for j in k+1..n {
            if x[j-1].0 > 0 {
                x[j] = (x[j-1].0 - 1, -1);
            } else {
                x[j] = (x[j-1].0, 0);
            }
        }
    }
}

fn main() {

    // let mut runs = vec![];
    // {
    //     for x in 1..300000 {
    //         if runrun(x) { runs.push(x) }
    //     }
    // }

    let mut sc = Scanner::new();
    let k: usize = sc.cin();
    let mut x = vec![(1, 0)];
    for i in 0..k-1 {
        // put!(i, runs[i], x.iter().map(|&(d, _)| d.to_string()).collect::<String>());
        inc(&mut x);
    }
    put!(x.iter().map(|&(d, _)| d.to_string()).collect::<String>());
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352