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


    fun meetsCondition(gcd: Int) : Boolean {
        // check M = gcd * K or Not
        val K = M / gcd
        return K >= N && (M % gcd) == 0
    }

    // Find lowerbound that meets condition
    /*
    fun lowerBound() : Int {
        var ng = M // left
        var ok = 1  // right

        while (Math.abs(ok - ng) > 1) {
            var mid = (ok + ng) / 2
            println("$$$$$$$$$$")
            println(mid)
            println(meetsCondition(mid))
            println("$$$$$$$$$$")
            if (meetsCondition(mid)) {
                ok = mid
            } else {
                ng = mid
            }
        }
        return ok
    }
    */
    println(
            (M/N downTo 1).first { meetsCondition(it) }
    )
}