import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

alias sread = () => readln.chomp();

void main()
{
    auto nm = aryread;
    auto n = nm[0];
    auto m = nm[1];

    long result = long.min;

    for (long i = 1; i * i <= m; i++)
    {
        if (i <= m / n && m % i == 0)
        {
            result = result.max(i);
            if (m / i <= m / n)
                result = result.max(m / i);
        }
    }
    writeln(result);
}
