def divisors(n)
  b = Array.new
  for i in 2..((n**0.5))
    if n % i == 0
      b.push(i)
    end
  end
  len = b.length
  len.times{|i|
    if n/b[len-1-i] != b[len-1-i]
      b.push(n/b[len-1-i])
    end
  }
  b
end
n,m = gets.chomp.split(" ").map(&:to_i)
max = 1
divisors(m).each do |i|
  if (m - i*n) >= 0 && (m - i*n) % i == 0
    max = i if i > max
  end
end
puts max