(set! *unchecked-math* true)


(defn input []
  (->> (clojure.string/split (read-line) #"\s")
    (map #(bigint %))))

(defn ProductandGCD [[N P]]
  (->> (range 1 (inc P))
    (map #(vector (Math/pow % N) %))
    (take-while #(<= (nth % 0)  P))
    (filter #(zero? (rem P (nth % 0))))
    (map #(nth % 1))
    (apply max)))



(->> (input)
  ProductandGCD
  println)