import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
readInt :: BC.ByteString -> Int
readInt = fst . fromJust . BC.readInt
strToInt s = (read :: String -> Int) s
getIntListBC = map readInt . BC.words <$> BC.getLine

main = do
    [n,m] <- (map read . words) <$> getLine
    let p = m `div` n
    
    let ans = head $ reverse [ a | a <- [1..p] , m `mod` a == 0]
    print $ ans