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

  def solve
    puts calc
  end

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

  def calc
    top.downto(1) do |i|
      next if m % i != 0
      j = m / i
      return i if j >= n
    end
  end
end

pb = Problem.new
pb.solve
