N, P = gets.chomp.split(' ').map(&:to_i)

if N == 1
    puts P
    exit
end

if P == 1
    puts P
    exit
end

require "prime"
ans = 1
Prime.prime_division(P).each do |n, a|
    t = a / N
    ans = ans * n * t if t > 0
end
puts ans