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

f :: Int -> Int -> Int
f 1 m= 1
f a m = if m `mod` a == 0
    　  then a
　　　  else f (a-1) m
        
main = do
    [n,m] <- (map read . words) <$> getLine
    let p = m `div` n
    
    let ans = f p m
    print $ ans