N, M = gets.chomp.split.map(&:to_i)
ans = 0
(1..M).each do |m|
  break if m*m > M and m > N
  if M % m == 0
    ans = [ans, M / m].max if m >= N
    ans = [ans, m].max if M / m >= N
  end
end
puts ans