n, m = gets.split.map(&:to_i)
a = 1
ans = 1
while a * a <= m
  flag = true
  if m % a != 0
   flag = false
  end

  if flag == true
    b = m / a
    if a * n <= m
      ans = [a, ans].max
    end
    if b * n <= m
      ans = [b, ans].max
    end
  end
    a += 1
end

puts ans