maxCheck :: Int -> Int
maxCheck m = floor $ sqrt (fromIntegral m)

calc :: Int -> Int -> Int
calc n m = case ds of
             [] -> 1
             otherwise -> m `div` (last ds)
  where ds = takeWhile (n <=) $ divosors m

main = do
  [n,m] <- map read . words <$> getLine
  print $ calc n m

divosors :: Int -> [Int]
divosors m = divosors'' ++ reverse divosors'
  where
    mc = maxCheck m
    divosors' = [i| i <- [1..mc], m `mod` i == 0]
    divosors'' = map (div m) divosors'