require 'prime'

def _divisors(primes, k)
  Enumerator.new do |y|
    if primes.size == k
      y << 1
    else
      p, e = primes[k]
      _divisors(primes, k + 1).each {|d|
        (e + 1).times {|e1|
          y << p ** e1 * d
        }
      }
    end
  end
end

def divisors(n)
  _divisors(Prime.prime_division(n), 0).to_a.sort
end

# def divisors(n)
#   n.prime_division.inject([1]) do |ary, (p, e)|
#     (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
#   end.sort
# end

n, m = gets.split.map(&:to_i)
puts m / divisors(m).bsearch { |i| i >= n }
