import Control.Monad
main = do
    k <- read <$> getLine 
    print $ ans !! (k-1)

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

f :: Integer -> [Integer]
f n = do
  ms <- [m-1,m,m+1]
  guard (0 <= ms && ms <= 9)
  res <- [10*n]
  return (res+ms)
  where m = n `mod` 10