solver::Int->Int->Int
solver m n =(maximum.concat.(map (\i->filter (\j->j*n<=m) [div m i,i])).(filter (\i->mod m i ==0)).(takeWhile (\i-> i^2 <=m))) [1..]

main::IO()
main=do
  (n:m:[])<-(return.(map read).words)=<<getLine
  print (solver m n)