Problem:
Score : 400 points

Problem Statement

You are given integers N and M.

Consider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N.

Constraints

All values in input are integers.

1 \leq N \leq 10^5

N \leq M \leq 10^9

Input

Input is given from Standard Input in the following format:

N M

Output

Print the maximum possible value of the greatest common divisor of a sequence a_1, a_2, ..., a_N that satisfies the condition.

Sample Input 1

3 14

Sample Output 1

2

Consider the sequence (a_1, a_2, a_3) = (2, 4, 8). Their greatest common divisor is 2, and this is the maximum value.

Sample Input 2

10 123

Sample Output 2

3

Sample Input 3

100000 1000000000

Sample Output 3

10000

Solution in JavaScript (node.js v5.12) (judge verdict: Accepted)

// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var N = parseInt(tmp[0], 10);
	var M = parseInt(tmp[1], 10);

    var divisors = divisor(M);
    var max = 0;
            for (var i =0;i < divisors.length;i++) {
                var d = divisors[i];
                if (M / d >= N) {
                    max = Math.max(max, d);
                }
            }

	//出力
	console.log('%d',max);
}
function divisor(n) {
        var res = [];
        for (var i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                res.push(i);
                if (n / i != i) {
                    res.push(n / i);
                }
            }
        }
        return res;
    }

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));