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)
k = 1
max = 1
while k <= m && k * n <= m
  if m % k == 0
    max = k
  end
  k += 1
end

p max
