require 'prime'
N, M = gets.split.map(&:to_i)
pd = M.prime_division.flat_map { |(n, e)| [n] * e }.sort
if M % N == 0
  puts M / N
  exit 0
end

INF = 1 << 60
$min = INF
def dfs_min(pd, i, n)
  return INF if n >= $min
  if n >= N
    $min = n
    return n
  end
  return INF if i == pd.size
  [
    dfs_min(pd, i + 1, n),
    dfs_min(pd, i + 1, n * pd[i])
  ].min
end

N2 = M / N
def dfs_max(pd, i, n)
  return -1 if n > N2
  return n if i == pd.size
  [
    dfs_max(pd, i + 1, n),
    dfs_max(pd, i + 1, n * pd[i])
  ].max
end

if N > M / N
  div = dfs_min(pd, 0, 1)
  ans = M / div
  puts ans
else
  ans = dfs_max(pd, 0, 1)
  puts ans
end

