module Main where

import Control.Monad
import Control.Applicative
import Data.List
import Text.Printf
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU

nextNumber n = [x | x <- [0 .. 9], abs (n - x) <= 1]
lunlunNumbers = [x * 10 + a | x <- 0 : lunlunNumbers, a <- if x == 0 then [0 .. 9] else nextNumber (mod x 10), x * 10 + a > 0]

main :: IO ()
main = do
    k <- readLn
    print $ lunlunNumbers !! (k - 1)
    
