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

def divisor(n)
  ans = []
  for i in (1..Math.sqrt(n))
    d, m = n.divmod(i)
    if m == 0
      ans << i   
      ans << d if i != d
    end
  end
  ans.sort! 
end

puts divisor(M).inject(1) {|acc, x| M / x >= N ? x : acc}