n,m = gets.strip.split.map(&:to_i)
#約数列挙
require 'prime'
def _divisors(primes, k)
  Enumerator.new do |y|
    if primes.size == k
      y << 1
    else
      p, e = primes[k]
      _divisors(primes, k + 1).each {|d|
        (e + 1).times {|e1|
          y << p ** e1 * d
        }
      }
    end
  end
end
def divisors(n)
  _divisors(Prime.prime_division(n), 0).to_a.sort
end
ary = divisors(m)
k = 0
for i in 0..ary.size-1
  if ary[i] <= m.to_f/n
    k += 1
  end
end
puts ary[k-1]