fun main(args: Array<String>) {
    val (N, M) = readInputLine().split(" ").map { it.toLong() }
    
    val divisors = mutableSetOf<Long>()
    
    for (i in 1..M) {
        if (i * i > M) {
            break
        }
        if (M % i == 0L) {
            divisors.add(i)
            divisors.add(M / i)
        }
    }
    
    var ans = 1L
    
    for (i in divisors.sorted()) {
        if (N > M / i) {
            break
        }
        
        ans = i
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}
