N, M = list(map(int, input().split()))



import math

class PrimeUtils:

    @staticmethod

    def primes_sieve(n):

        sieve = [True] * (n + 1)

        for i in range(2, n + 1):

            if sieve[i]:

                for j in range(i + i, n + 1, i):

                    sieve[j] = False

        return [i for i, x in enumerate(sieve[2:], 2) if x]



def f():

    for p in PrimeUtils.primes_sieve(math.ceil(math.sqrt(M))):

        if M % p == 0:

            for x in range(N, (M//2) + 1):

                if M % x == 0:

                    return M // x

            else:

                return 1

    return 1

print((f()))
import math, collections, itertools, functools, operator

class PrimeUtils:

    @staticmethod

    def primes_sieve(n):

        sieve = [True] * (n + 1)

        for i in range(2, n + 1):

            if sieve[i]:

                for j in range(i + i, n + 1, i):

                    sieve[j] = False

        return [i for i, x in enumerate(sieve[2:], 2) if x]

    @staticmethod

    # Prime Factor Decomposition

    def pfd(n):

        rn = math.ceil(math.sqrt(n))

        primes = PrimeUtils.primes_sieve(rn)



        factors = []

        cur = n

        for p in primes:

            while True:

                div, rem = divmod(cur, p)

                if rem == 0:

                    factors.append(p)

                    cur = div

                else:

                    break

        if cur != 1 or not factors:

            factors.append(cur)

        return factors

    @staticmethod

    # Returns a list of factors

    def factors(n):

        pf = PrimeUtils.pfd(n)

        pfc = collections.Counter(pf)

        ppv = [[pow(p, i) for i in range(n+1)] for p,n in list(pfc.items())]

        return [functools.reduce(operator.imul, x) for x in itertools.product(*ppv)]



N, M = list(map(int, input().split()))

for factor in sorted(PrimeUtils.factors(M)):

    if N <= factor:

        print((M // factor))

        break

else:

    print((1))
N, M = list(map(int, input().split()))
import math


class PrimeUtils:
    @staticmethod
    def primes_sieve(n):
        sieve = [True] * (n + 1)
        for i in range(2, n + 1):
            if sieve[i]:
                for j in range(i + i, n + 1, i):
                    sieve[j] = False
        return [i for i, x in enumerate(sieve[2:], 2) if x]


def f():
    for p in PrimeUtils.primes_sieve(math.ceil(math.sqrt(M))):
        if M % p == 0:
            for x in range(N, (M // 2) + 1):
                if M % x == 0:
                    return M // x
            else:
                return 1
    return 1


print((f()))

import math, collections, itertools, functools, operator


class PrimeUtils:
    @staticmethod
    def primes_sieve(n):
        sieve = [True] * (n + 1)
        for i in range(2, n + 1):
            if sieve[i]:
                for j in range(i + i, n + 1, i):
                    sieve[j] = False
        return [i for i, x in enumerate(sieve[2:], 2) if x]

    @staticmethod
    # Prime Factor Decomposition
    def pfd(n):
        rn = math.ceil(math.sqrt(n))
        primes = PrimeUtils.primes_sieve(rn)
        factors = []
        cur = n
        for p in primes:
            while True:
                div, rem = divmod(cur, p)
                if rem == 0:
                    factors.append(p)
                    cur = div
                else:
                    break
        if cur != 1 or not factors:
            factors.append(cur)
        return factors

    @staticmethod
    # Returns a list of factors
    def factors(n):
        pf = PrimeUtils.pfd(n)
        pfc = collections.Counter(pf)
        ppv = [[pow(p, i) for i in range(n + 1)] for p, n in list(pfc.items())]
        return [functools.reduce(operator.imul, x) for x in itertools.product(*ppv)]


N, M = list(map(int, input().split()))
for factor in sorted(PrimeUtils.factors(M)):
    if N <= factor:
        print((M // factor))
        break
else:
    print((1))

-N, M = list(map(int, input().split())) -import math +import math, collections, itertools, functools, operator +    @staticmethod +    # Prime Factor Decomposition +    def pfd(n): +        rn = math.ceil(math.sqrt(n)) +        primes = PrimeUtils.primes_sieve(rn) +        factors = [] +        cur = n +        for p in primes: +            while True: +                div, rem = divmod(cur, p) +                if rem == 0: +                    factors.append(p) +                    cur = div +                else: +                    break +        if cur != 1 or not factors: +            factors.append(cur) +        return factors -def f(): -    for p in PrimeUtils.primes_sieve(math.ceil(math.sqrt(M))): -        if M % p == 0: -            for x in range(N, (M // 2) + 1): -                if M % x == 0: -                    return M // x -            else: -                return 1 -    return 1 +    @staticmethod +    # Returns a list of factors +    def factors(n): +        pf = PrimeUtils.pfd(n) +        pfc = collections.Counter(pf) +        ppv = [[pow(p, i) for i in range(n + 1)] for p, n in list(pfc.items())] +        return [functools.reduce(operator.imul, x) for x in itertools.product(*ppv)] -print((f())) +N, M = list(map(int, input().split())) +for factor in sorted(PrimeUtils.factors(M)): +    if N <= factor: +        print((M // factor)) +        break +else: +    print((1))