import sys

from collections import deque

import copy

import math

import numpy as np



def get_read_func(fileobject):

    if fileobject == None :

        return raw_input

    else:

        return fileobject.readline



def divisor_sub(p, q):

    a = []

    for i in range(0, q + 1):

        a.append(p ** i)

    return a



def factorization(n):

    def factor_sub(n, m):

        c = 0

        while n % m == 0:

            c += 1

            n /= m

        return c, n

    #

    buff = []

    c, m = factor_sub(n, 2)

    if c > 0: buff.append((2, c))

    c, m = factor_sub(m, 3)

    if c > 0: buff.append((3, c))

    x = 5

    while m >= x * x:

        c, m = factor_sub(m, x)

        if c > 0: buff.append((x, c))

        if x % 6 == 5:

            x += 2

        else:

            x += 4

    if m > 1: buff.append((m, 1))

    return buff



def divisor(n):

    xs = factorization(n)

    ys = divisor_sub(xs[0][0], xs[0][1])

    for p, q in xs[1:]:

        ys = [x * y for x in divisor_sub(p, q) for y in ys]

    return sorted(ys)



def is_prime(x):

    if x < 2: return False

    if x == 2 or x == 3 or x == 5: return True

    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False

    prime = 7

    step = 4

    while prime <= math.sqrt(x):

        if x % prime == 0: return False



        prime += step

        step = 6 - step



    return True





def main():

    if len(sys.argv) > 1:

        f = open(sys.argv[1])

    else:

        f = None

    read_func = get_read_func(f);

    input_raw = read_func().strip().split()

    [N, M] = [int(input_raw[0]), int(input_raw[1])]

    if N == 1:

        print(M)

        exit()

    if is_prime(M):

        print(1)

        exit()

##    div_list = divisor(M)

##    div_list.sort(reverse = True)

##

##    for num in div_list:

##        if M % num == 0 and M/num >= N:

##            print num

##            exit()



    max_p = 0

    for p in range(int(math.sqrt(M) + 0.5) , 0, -1):



        if(M % p == 0):

            q = M/p

            if q >= N:

                max_p = max(p, max_p)

            if p >= N:

                max_p = max(q, max_p)

    print(max_p)



if __name__ == '__main__':

    main()
import sys

from collections import deque

import copy

import math

def get_read_func(fileobject):

    if fileobject == None :

        return raw_input

    else:

        return fileobject.readline



def main():

    if len(sys.argv) > 1:

        f = open(sys.argv[1])

    else:

        f = None

    read_func = get_read_func(f);

    input_raw = read_func().strip().split()

    [N, M] = [int(input_raw[0]), int(input_raw[1])]



    ans = 0

    for i in range(1, int(math.sqrt(M)) + 2):

        if M % i == 0:

            j = M/i

            if M/i >= N:

                ans = max(ans, i)

            if M/j >= N:

                ans = max(ans, j)

    print(ans)









if __name__ == '__main__':

    main()

import sys
from collections import deque
import copy
import math
import numpy as np


def get_read_func(fileobject):
    if fileobject == None:
        return raw_input
    else:
        return fileobject.readline


def divisor_sub(p, q):
    a = []
    for i in range(0, q + 1):
        a.append(p**i)
    return a


def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n /= m
        return c, n

    #
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0:
        buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0:
        buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0:
            buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1:
        buff.append((m, 1))
    return buff


def divisor(n):
    xs = factorization(n)
    ys = divisor_sub(xs[0][0], xs[0][1])
    for p, q in xs[1:]:
        ys = [x * y for x in divisor_sub(p, q) for y in ys]
    return sorted(ys)


def is_prime(x):
    if x < 2:
        return False
    if x == 2 or x == 3 or x == 5:
        return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0:
        return False
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0:
            return False
        prime += step
        step = 6 - step
    return True


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f)
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), int(input_raw[1])]
    if N == 1:
        print(M)
        exit()
    if is_prime(M):
        print(1)
        exit()
    ##    div_list = divisor(M)
    ##    div_list.sort(reverse = True)
    ##
    ##    for num in div_list:
    ##        if M % num == 0 and M/num >= N:
    ##            print num
    ##            exit()
    max_p = 0
    for p in range(int(math.sqrt(M) + 0.5), 0, -1):
        if M % p == 0:
            q = M / p
            if q >= N:
                max_p = max(p, max_p)
            if p >= N:
                max_p = max(q, max_p)
    print(max_p)


if __name__ == "__main__":
    main()

import sys
from collections import deque
import copy
import math


def get_read_func(fileobject):
    if fileobject == None:
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f)
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), int(input_raw[1])]
    ans = 0
    for i in range(1, int(math.sqrt(M)) + 2):
        if M % i == 0:
            j = M / i
            if M / i >= N:
                ans = max(ans, i)
            if M / j >= N:
                ans = max(ans, j)
    print(ans)


if __name__ == "__main__":
    main()

-import numpy as np - - -def divisor_sub(p, q): -    a = [] -    for i in range(0, q + 1): -        a.append(p**i) -    return a - - -def factorization(n): -    def factor_sub(n, m): -        c = 0 -        while n % m == 0: -            c += 1 -            n /= m -        return c, n - -    # -    buff = [] -    c, m = factor_sub(n, 2) -    if c > 0: -        buff.append((2, c)) -    c, m = factor_sub(m, 3) -    if c > 0: -        buff.append((3, c)) -    x = 5 -    while m >= x * x: -        c, m = factor_sub(m, x) -        if c > 0: -            buff.append((x, c)) -        if x % 6 == 5: -            x += 2 -        else: -            x += 4 -    if m > 1: -        buff.append((m, 1)) -    return buff - - -def divisor(n): -    xs = factorization(n) -    ys = divisor_sub(xs[0][0], xs[0][1]) -    for p, q in xs[1:]: -        ys = [x * y for x in divisor_sub(p, q) for y in ys] -    return sorted(ys) - - -def is_prime(x): -    if x < 2: -        return False -    if x == 2 or x == 3 or x == 5: -        return True -    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: -        return False -    prime = 7 -    step = 4 -    while prime <= math.sqrt(x): -        if x % prime == 0: -            return False -        prime += step -        step = 6 - step -    return True -    if N == 1: -        print(M) -        exit() -    if is_prime(M): -        print(1) -        exit() -    ##    div_list = divisor(M) -    ##    div_list.sort(reverse = True) -    ## -    ##    for num in div_list: -    ##        if M % num == 0 and M/num >= N: -    ##            print num -    ##            exit() -    max_p = 0 -    for p in range(int(math.sqrt(M) + 0.5), 0, -1): -        if M % p == 0: -            q = M / p -            if q >= N: -                max_p = max(p, max_p) -            if p >= N: -                max_p = max(q, max_p) -    print(max_p) +    ans = 0 +    for i in range(1, int(math.sqrt(M)) + 2): +        if M % i == 0: +            j = M / i +            if M / i >= N: +                ans = max(ans, i) +            if M / j >= N: +                ans = max(ans, j) +    print(ans)