module Main where import Control.Monad to10 :: Int -> Int to10 x = (1 * x ^ 1) + (7 * x ^ 0) main :: IO () main = do a <- readLn :: IO Int let bs = filter ((== a) . to10) $ [2 .. 100] if null bs then print (-1) else print $ head bs