n,m = list(map(int,input().split()))



max_cnd = m//n



for i in range(max_cnd):

    if m % (max_cnd-i) == 0:

        print((max_cnd-i))

        exit()
n,m = list(map(int,input().split()))





def make_divisors(n):

    divisors = []

    for i in range(1, int(n**0.5)+1):

        if n % i == 0:

            divisors.append(i)

            if i != n // i:

                divisors.append(n//i)



    divisors.sort(reverse=True)

    return divisors





cnd = make_divisors(m)



for i in range(len(cnd)):

    if m // cnd[i] >= n:

        print((cnd[i]))

        exit()



n, m = list(map(int, input().split()))
max_cnd = m // n
for i in range(max_cnd):
    if m % (max_cnd - i) == 0:
        print((max_cnd - i))
        exit()

n, m = list(map(int, input().split()))


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    divisors.sort(reverse=True)
    return divisors


cnd = make_divisors(m)
for i in range(len(cnd)):
    if m // cnd[i] >= n:
        print((cnd[i]))
        exit()

-max_cnd = m // n -for i in range(max_cnd): -    if m % (max_cnd - i) == 0: -        print((max_cnd - i)) + + +def make_divisors(n): +    divisors = [] +    for i in range(1, int(n**0.5) + 1): +        if n % i == 0: +            divisors.append(i) +            if i != n // i: +                divisors.append(n // i) +    divisors.sort(reverse=True) +    return divisors + + +cnd = make_divisors(m) +for i in range(len(cnd)): +    if m // cnd[i] >= n: +        print((cnd[i]))