readInt :: IO Int
readInt = read <$> getLine

func :: Int -> [Int]
func x | r == 0    = [x * 10, x * 10 + 1]
       | r == 9    = [x * 10 + 8, x * 10 + 9]
       | otherwise = [(x * 10 + r - 1) .. (x * 10 + r + 1)]
    where r = mod x 10

lunlun :: [Int]
lunlun = [1 .. 9] ++ concatMap func lunlun

main = do
    k <- readInt
    print $ lunlun !! k