require 'prime'

n, p = gets.split.map(&:to_i)
h = Hash.new(0)
g = Prime::EratosthenesGenerator.new
d = g.next
while d < Math.sqrt(p)
  q = p
  while q % d == 0
    h[d] += 1
    q /= d
  end
  d = g.next
end
if h == {} || p == 1
  puts 1
elsif n == 1
  puts p
else
  ans = 1
  h.sort_by{|k, v| -v}.each do |k, v|
    ans *= k if v >= n
  end
  puts ans
end