# frozen_string_literal: true

def factor(n)
  return [1] if n == 1

  `factor #{n}|sed -r 's/[0-9]+://g'|tr ' ' '\n'|sort -n`.split.map(&:to_i)
end

def uniq_factor(n)
  `factor #{n}|sed -r 's/[0-9]+://g'|tr ' ' '\n'|sort -n|uniq`.split.map(&:to_i)
end

n, p = gets.split(' ').map(&:to_i)

factors = factor(p)

factors_map = Hash.new(0)
factors.each do |i|
  factors_map[i] += 1
end

ans = 1
factors_map.each do |key, val|
  ans *= val / n * key if val >= n
end

puts ans
