main = do
  line <- getLine
  let 
    x = read $ head $ words line :: Int
    power a b = power_ 1 a b 
    power_ p a b 
      | b > 0     = power_ (p*a) a (b-1)
      | otherwise = p
    func i j x 
      | x == 1          = 1
      | power i j <= x  = max (func (i+1) j x) (func i (j+1) x)
      | otherwise       = choice (power (i-1) j) (power i (j-1))
    choice a b
      | a <= x && b <= x  = max a b
      | otherwise         = min a b
    in
      putStrLn $ show $ func 2 2 x
  
