N,M=gets.chomp.split(" ").map { |e| e.to_i  }

const = 0
val = Math.sqrt(M)

if M%N == 0
  puts M/N
  exit
end
a=[]
indx = 0
for i in 1..val+1 do
  if M % i == 0
    a[indx] = i
    a[indx+1] = M/i
    indx += 2
  end
end

for i in a do
  if  M % i == 0 && N*i <= M
     const = i
  end
end

puts const
