import scala.io.StdIn.readLine

object Main extends App {
  val Array(n, m) = readLine().split(' ').map(_.toInt)
  
  if (n == 1)
    println(m)
  else {
    var i: Int = 1
    val divisors = scala.collection.mutable.ArrayBuffer.empty[Int]
    while (i * i <= m) {
      if (m % i == 0) {
        divisors += i
        if (i * i != m) divisors += (m / i)
      }
      i = i + 1
    }
    println(divisors.filter(_ <= m / n).max)
  }
}