import java.util.*
import java.lang.Math.*

fun main(args: Array<String>) {
  val (n, m) = readLine()!!.split(" ").map { it.toInt() }
  var list = ArrayList<Int>()
  val sqrtM = sqrt(m.toDouble()).toInt()
  for (i in 1..sqrtM) {
    if (m % i == 0) {
      if (i <= m / n) list.add(i)
      if (i * i != m && m / i <= m / n) list.add(m / i)
    }
  }
  val ans = list.max()
  println(ans)
}
