import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto nm = readints;
    int n = nm[0], m = nm[1];

    long ans = 0;
    for (long i = 1; i * i <= m; i++) {
        if (m % i == 0) {
            foreach (g; [i, m / i]) {
                if (m >= g * n) { // a_1, a_2, .., a_n の和(約数)が m を超えてはいけない
                    ans = max(ans, g);
                }
            }
        }
    }
    writeln(ans);
}
