import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

fun <A : Comparable<A>> min(a: A, b: A) = if (a < b) a else b

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toLong()
        val M = sc.next().toLong()
        var f = M
        var i = 2L
        while (i * i <= M) {
            if (M % i == 0L) {
                val i2 = M / i
                if (i >= N) f = min(f, i)
                if (i2 >= N) f = min(f, i2)
            }
            i++
        }
        if (N == 1L) pw.println(M)
        else pw.println(M / f)
    }
}
