# AGC112 D - Partition

from math import floor

def divisor(n): 

    i = 1

    table = []

    while i * i <= n:

        if n%i == 0:

            table.append(i)

            table.append(n//i)

        i += 1

    table = list(set(table))

    return table





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



n_max=floor(m/n)

div_m=divisor(m)

div_m.sort(reverse=True)

ans=0

for i in div_m:

    if i<=n_max:

        print(i)

        exit()

def create_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



from math import floor

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

n_max=floor(m/n)

d=create_divisors(m)

for di in d:

  if di<=n_max:

    print(di)

    exit(0)
# AGC112 D - Partition
from math import floor


def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n // i)
        i += 1
    table = list(set(table))
    return table


n, m = list(map(int, input().split()))
n_max = floor(m / n)
div_m = divisor(m)
div_m.sort(reverse=True)
ans = 0
for i in div_m:
    if i <= n_max:
        print(i)
        exit()

def create_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


from math import floor

n, m = list(map(int, input().split()))
n_max = floor(m / n)
d = create_divisors(m)
for di in d:
    if di <= n_max:
        print(di)
        exit(0)

-# AGC112 D - Partition -from math import floor +def create_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 -def divisor(n): -    i = 1 -    table = [] -    while i * i <= n: -        if n % i == 0: -            table.append(i) -            table.append(n // i) -        i += 1 -    table = list(set(table)) -    return table - +from math import floor -div_m = divisor(m) -div_m.sort(reverse=True) -ans = 0 -for i in div_m: -    if i <= n_max: -        print(i) -        exit() +d = create_divisors(m) +for di in d: +    if di <= n_max: +        print(di) +        exit(0)