let ans = ref 0
let f g n = let rec f i = if i * i <= n then (if n mod i = 0 then (g i; if i <> n / i then g (n / i)); f (i + 1)) in f 1
let _ = Scanf.scanf "%d %d" @@ fun n m -> f (fun d -> if m / d >= n then ans := max !ans d) m; Printf.printf "%d\n" !ans