import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];
    foreach_reverse (x; 1..10^^6) if (M % x == 0 && M / x >= N) {
        writeln(x);
        return;
    }
}