
import Data.Char

lunlun :: String -> Bool
lunlun [n] = True
lunlun (a1:a2:as)
	| 1 >= abs ((ord a1) - (ord a2)) = lunlun (a2:as)
	| otherwise = False
lunlun _ = False

lunluns = filter (lunlun) . map (show) $ [1..]

main :: IO ()
main = interact $ show . (\n -> lunluns !! (n - 1)) . read

