import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine

main = do
    k <- getInt
    let a = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
    putStrLn . flip (!!) (k - 1) . concat $ iterate solve a

solve :: [String] -> [String]
solve a = concat $ map f a

f :: String -> [String]
f cs | lc == 9 = [cs ++ "8", cs ++ "9"]
     | lc == 0 = [cs ++ "0", cs ++ "1"]
     | otherwise = [cs ++ show (lc - 1), cs ++ show lc, cs ++ show (lc + 1)]
     where lc = (read cs) `mod` 10