fun readInt () =
  TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn

val SOME n = readInt ()
val SOME m = readInt ()

fun dividers acc i n =
  if n < i * i
  then acc
  else if n = i * i then i :: acc
  else dividers (if 0 < n mod i then acc else i :: (n div i) :: acc) (i + 1) n
val dividers = dividers [] 1

val () =
  print
    (Int.toString
      (foldl Int.max 1
        (List.filter (fn d => n <= m div d) (dividers m))) ^ "\n")
