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

factors = 1.upto(Math.sqrt(m).to_i).select do |i|
  m % i == 0
end

factors.sort.reverse.each do |factor|
  rest = m / factor
  if rest >= n
    puts factor
    exit
  end
end

