N,M=$<.read.split.map(&:to_i)
require 'prime'

def f(a,n)
    if a.empty?
        return (n*N<=M&&M%n==0 ? n : 1)
    end
    p,mi = a[0]
    max = 0
    (mi+1).times do |i|
        x = f(a[1..-1], n*(p**i))
        max = x if max < x
    end
    max
end

# p Prime.prime_division(M)
p f(Prime.prime_division(M),1)

