main=getLine>>=print.solve.map read.words
solve [n,m]
 | n==1 = m
 | otherwise = go divs
 where
 go (d:divs)
  | d*n<=m = d
  | otherwise = go divs
 divs = f.floor.sqrt.fromIntegral$m
 f 1 = [1]
 f d
  | m`mod`d==0 = d:f(d-1)
  | otherwise = f(d-1)
