N,M=gets.split.map &:to_i
require 'prime'
class Integer
  def divisor_list
    return [] if self <= 0
    return [1] if self == 1
    prime_division.map{|e| [*(0..e.last)].map{|v| e.first ** v }}.inject{|res, e| res.map{|t| e.map{|v| t * v}}.flatten}.sort
  end
end
class Array
  def upper_bound(val)
    a = 0
    b = size
    while a < b
      c = (( a + b ) / 2 ).to_i
      if val < at(c)
        b = c
      else
        a = c + 1
      end
    end
    b
  end
  def lower_bound(val)
    a = 0
    b = size
    while a < b
      c = (( a + b ) / 2 ).to_i
      if val <= at(c)
        b = c
      else
        a = c + 1
      end
    end
    b
  end
end
p M.divisor_list.select{|x|x*N<=M}[-1]