using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace debug
{
    class main
    {
        static void Main(string[] args)
        {
            //問題クラスを展開
            ProgramD a = new ProgramD();
            a.main();//実行する

        }

    }

    class ProgramA
    {
        public void main()
        {
            //数値入力する
            string[] s = Console.ReadLine().Split(' ');


            //それぞれの文字列で答えを出す
            if ((int.Parse(s[0]) * int.Parse(s[1])) % 2 == 1)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

        }
    }

    class ProgramB
    {
        public void main()
        {

            //入力
            string input = Console.ReadLine();
            int n = int.Parse(input);

            string[] num = new string[n];


            //char型で読み込み、int型に変換。そこから数を足して、char型に戻す
            for (int i = 0; i < n; i++)
            {
                string s = Console.ReadLine();

                if (num.Contains(s) == true)
                {
                    Console.WriteLine("No");
                    return;
                }

                if (i == 0)
                {
                    num[0] = s;
                }
                else
                {
                    if (num[i - 1][num[i - 1].Length - 1] != s[0])
                    {
                        Console.WriteLine("No");
                        return;
                    }

                    num[i] = s;
                }


            }

            Console.WriteLine("Yes");

        }
    }

    class ProgramC
    {
        public void main()
        {

            //入力
            string[] input = Console.ReadLine().Split();
            long n = long.Parse(input[0]);
            long x = long.Parse(input[1]);

            string[] s = Console.ReadLine().Split();
            long[] a = new long[n];

            //
            for (int i = 0; i < n; i++)
                a[i] = Math.Abs(long.Parse(s[i]) - x);

            if (n == 1)
            {
                Console.WriteLine(a[0]);
                return;
            }

            long ans = gcd(a[0], a[1]);

            for (int i = 2; i < n; i++)
                ans = gcd(ans, a[i]);

            //答え出力
            Console.WriteLine(ans);

        }

        /*最大公約数を求める関数*/
        static long gcd(long p, long q)
        {
            if (p < q)
            {
                long temp = p;
                p = q;
                q = temp;
            }

            long r = 1;

            while (r != 0)
            {
                r = p % q;
                p = q;
                q = r;
            }

            return p;
        }
    }

    class ProgramD
    {
        public void main()
        {

            //入力
            string[] input = Console.ReadLine().Split();
            long n = long.Parse(input[0]);
            long m = long.Parse(input[1]);

            long ans = 1;

            //2変数に分離
            for (int i = 1; i <= Math.Sqrt(m); i++)
            {
                if (m % i == 0)
                {
                    if (m/i >= n)
                    {
                        ans = Math.Max(ans, i);
                        if (i >= n)
                            ans = Math.Max(ans, m / i);
                    }
                }

            }

            //答え出力
            Console.WriteLine(ans);
           

        }
    }




  

}






Measured memory_bytes: 13140