fun main(args: Array<String>) {
    val (n,m)= readLine()!!.split(" ").map{it.toLong()}
    (1L..Math.sqrt(m.toDouble()).toLong())
            .filter { m%it==0L }
            .map { listOf(it, m/it) }.flatten()
            .sorted()
            .last{ it*n<=m }
            .let { println(it) }

}