require "prime"

def each_div(primes)
  max = primes.map{|prime| prime[1]}.inject{|acc, count| acc *= (count + 1)}

  use_counts = Array.new(primes.size, 0)
  (1..max).each do
    use_counts[0] += 1

    (0..(use_counts.size - 1)).each do |i|
      if use_counts[i] > primes[i][1]
        use_counts[i] = 0
        use_counts[i + 1] += 1
      else
        break
      end
    end

    div = 1
    use_counts.each_with_index do |count, i|
      div *= primes[i][0] ** count
    end

    yield div
  end
end

N, M =  STDIN.gets.chomp.split(" ").map(&:to_i)

primes = Prime.prime_division(M).select{|prime| prime[0] <= M / N}

divs = [1]
each_div(primes){|div| divs << div if div <= M / N}
answer = divs.uniq.select{|div| div <= M / N}.max
puts answer
