n,m = gets.chomp.split.map(&:to_i)
yakusu = []

for i in 1..(m**(1/2.0)).to_i
  if m % i == 0
    yakusu << i
    yakusu << m/i
  end
end
yakusu.sort! {|a, b| b <=> a }

yakusu.each do |num|
  if num <= m/n
    print(num)
    break
  end
end
