fun max(x: Int, y: Int): Int {
    return if(x > y) x else y
}


fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map { it.toInt() }

    var ans = 1
    var d = 1

    while (d * d <= M) {
        if (M%d==0) {
            val e = M/d
            if (M/N >= d)
                ans = max(ans, d)
            if (M/N >= e)
                ans = max(ans, e)
        }
        d += 1
    }
    println(ans)
}