(set! *unchecked-math* true)


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

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



(->> (input)
  ProductandGCD
  println)