require 'prime'

def gcd(l, r)
  return r if l%r==0
  gcd(r, l%r)
end

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

if m.primes?
  p 1
  exit
end

result = 0
current = m/n

(m/n).times do |num|
  diff = m%current
  tmp_result = gcd(current + diff, current)
  result = tmp_result if tmp_result > result
  current -= 1
end

p result

