let n, m = Scanf.scanf " %d %d" @@ fun a b -> a, b
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 ans = ref 0
let g d = if m / d >= n then ans := max !ans d
let _ = f g m; Printf.printf "%d\n" !ans