main=print.solve.map read.words=<<getLine
solve[n,m]
  |v<n=1
  |otherwise=head$[i|i<-reverse[1..m`div`n],m`mod`i==0]
  where v=f 2 m
f i k
  |i*i>k=k
  |r==0=q
  |otherwise=f(i+1)k
  where(q,r)=k`mod`i