module Main where

main :: IO ()
main = do
    k <- read <$> getLine 
    print $ ans !! (k-1)

ans = [1..9] ++ concatMap f ans

f :: Integer -> [Integer]
f n 
    |   m == 0  =   [10*n + m,10*n + m + 1]
    |   m == 9  =   [10*n+m-1,10*n+m]
    |   otherwise   =   [10*n+m-1,10*n+m,10*n+m+1]
    where m = n `mod` 10