from math import *



def main():

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

    special_value = M//N

    divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))

    divisor_set = divisor_set.union(M//j for j in divisor_set)

    print((int(max([i for i in divisor_set if special_value >= i]))))

    return



main()
from math import *



def main():

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

    special_value = M//N

    divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))

    divisor_set = divisor_set.union(M//j for j in divisor_set)

    print((int(max(divisor_set, key=lambda x: x if special_value >= x else -1))))



    return



main()

from math import *


def main():
    N, M = list(map(int, input().split()))
    special_value = M // N
    divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
    divisor_set = divisor_set.union(M // j for j in divisor_set)
    print((int(max([i for i in divisor_set if special_value >= i]))))
    return


main()

from math import *


def main():
    N, M = list(map(int, input().split()))
    special_value = M // N
    divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
    divisor_set = divisor_set.union(M // j for j in divisor_set)
    print((int(max(divisor_set, key=lambda x: x if special_value >= x else -1))))
    return


main()

-    print((int(max([i for i in divisor_set if special_value >= i])))) +    print((int(max(divisor_set, key=lambda x: x if special_value >= x else -1))))