import Data.Char import Data.List main = getLine >>= putStrLn . septenary . read septenary n | n == 0 = "0" | otherwise = reverse (unfoldr sep n) where sep x | x == 0 = Nothing | otherwise = Just (intToDigit m, d) where (d,m) = divMod x 7