require 'prime'

n, b = gets.chomp.split.map(&:to_i)

if b == 1
  puts 1
  exit
end

f = []
b.prime_division.each do |i|
  i[1].times do
    f.push(i[0])
  end
end

while true
  l = f.length
  (l/2).times do |i|
    f[i] = f[i] * f[l - i - 1]
    f.delete_at(l - i - 1)
    if l == 1
      f = [1]
      break
    end
    break if f.length == n
  end
  if l == 1
    f = [1]
    break
  end
  break if f.length == n
  f.sort!
end

puts f.inject(:gcd)