(defn inner [X x]
  (let [tmp (->> (map #(Math/pow x %) (range 2 100))
              (take-while #(<= % X)))]
    (if ((complement empty?) tmp)
      (->> (apply max tmp)
        int)
      0)))


(defn Exponential [X]
  (->> (range 2 (inc X))
    (map #(inner X %))
    (cons 1)
    (apply max)))



(-> (int (read))
  Exponential
  println)