class Problem
  attr_accessor :a, :b, :n, :m, :h, :w, :ans
  def initialize
    @n, @m = gets.to_s.split.map{ |v| v.to_i }
    @ans = 0
  end

  def solve
    calc
    puts ans
  end

  def top
    @top ||= Math.sqrt(m).to_i
  end

  def chmax(v)
    @ans = v if @ans < v
  end

  def calc
    each_div do |i,j|
      chmax(i) if j >= n
      chmax(j) if i >= n
    end
  end

  def each_div
    1.upto(top) do |i|
      next if m % i != 0
      j = m / i
      yield i, j
      yield j, i
    end
  end
end

pb = Problem.new
pb.solve