import random



def is_prime(q,k=50):

    if q == 2: return True

    if q < 2 or q&1 == 0: return False

    d = (q-1)>>1

    while d&1 == 0:

        d >>= 1

    for i in range(k):

        a = random.randint(1,q-1)

        t = d

        y = pow(a,t,q)

        while t != q-1 and y != 1 and y != q-1: 

            y = pow(y,2,q)

            t <<= 1

        if y != q-1 and t&1 == 0:

            return False

    return True



n,m=(int(i) for i in input().split(' '))

for i in range(1,n):

  if m%i==0 and (is_prime(i) or i==1) and is_prime(m//i) and (i==1 or m//i<n):

    print('1')

    exit()

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

  if i==m:

    print((1))

    break

  if m%i==0:

    print((m//i))

    break

  if m-i-n>0 and m%(m-i-n)==0 and m//(m-i-n)>n:

    print((m-i-n))

    break

import random



def is_prime(q,k=50):

    if q == 2: return True

    if q < 2 or q&1 == 0: return False

    d = (q-1)>>1

    while d&1 == 0:

        d >>= 1

    for i in range(k):

        a = random.randint(1,q-1)

        t = d

        y = pow(a,t,q)

        while t != q-1 and y != 1 and y != q-1: 

            y = pow(y,2,q)

            t <<= 1

        if y != q-1 and t&1 == 0:

            return False

    return True



n,m=(int(i) for i in input().split(' '))

for i in range(1,n):

  if m%i==0 and (is_prime(i) or i==1) and is_prime(m//i) and (i==1 or m//i<n):

    print('1')

    exit()

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

  if i==m:

    print((1))

    break

  if m%i==0:

    print((m//i))

    break
import random


def is_prime(q, k=50):
    if q == 2:
        return True
    if q < 2 or q & 1 == 0:
        return False
    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True


n, m = (int(i) for i in input().split(" "))
for i in range(1, n):
    if (
        m % i == 0
        and (is_prime(i) or i == 1)
        and is_prime(m // i)
        and (i == 1 or m // i < n)
    ):
        print("1")
        exit()
for i in range(n, m + 1):
    if i == m:
        print((1))
        break
    if m % i == 0:
        print((m // i))
        break
    if m - i - n > 0 and m % (m - i - n) == 0 and m // (m - i - n) > n:
        print((m - i - n))
        break

import random


def is_prime(q, k=50):
    if q == 2:
        return True
    if q < 2 or q & 1 == 0:
        return False
    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True


n, m = (int(i) for i in input().split(" "))
for i in range(1, n):
    if (
        m % i == 0
        and (is_prime(i) or i == 1)
        and is_prime(m // i)
        and (i == 1 or m // i < n)
    ):
        print("1")
        exit()
for i in range(n, m + 1):
    if i == m:
        print((1))
        break
    if m % i == 0:
        print((m // i))
        break

-    if m - i - n > 0 and m % (m - i - n) == 0 and m // (m - i - n) > n: -        print((m - i - n)) -        break