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

# a_1 + ... + a_n = M
# d * (b_1 + ... + b_n) = d * Q
# b_1 + ... + b_n = Q
# 1 + ... + 1 + (Q - (N - 1)) = Q
# a_1 = M / N

sq = Math.sqrt(m).ceil
k = 1
max = 1
1.upto(sq) do |k|
  next if m % k != 0 
    
  max = [k, max].max if k * n <= m
  max = [m / k, max].max if n <= k
end

p max
