n,m = gets.chomp.split.map(&:to_i)
max = 1
# i = 2
# while i<=m**(1/2.0) && i<= m/n
#   # puts([i,max])
#   if m % i == 0
#     max = [max, i].max
#   end
#   i+=1
# end
for i in 2..(m/n)
  if m % i == 0
    max = [max, i].max
  end
end



print(max)
