stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll linf=0x3f3f3f3f3f3f3f3f;

int main() {

#ifdef LOCAL

    freopen("in.txt", "r", stdin);

#endif

    ll a, b;

    while (~scanf("%lld%lld", &a, &b)) {

        ll ans=1;

        for (ll i = 1; i * i <= b; i++) {

            if (b % i == 0) {

                if (i * a <= b) {

                    ll tmp = b/i;

                    if (tmp * a <= b) ans = max(max(i, tmp), ans);

                    else ans = max(ans, i);

                } else {

                    break;

                }

            }

        }

        printf("%lld\n", ans);

    }



}


// Faster C++ solution for the same problem (measured speedup: 0.915934178078435x):
#include <iostream>

#include <string>

#include <stdio.h>

#include <queue>

#include <stack>

#include <string.h>

#include <algorithm>

#include <math.h>

//#include <bits/stdc++.h>

#define ll long long

#define wtcl return

using namespace std;



inline int read()

{

	ll s = 0, f = 1;

	char ch = getchar();

	for(; ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = - 1;

	for(; ch >= '0' && ch <= '9'; ch = getchar()) s = ((s << 3ll) + (s << 1ll) + (ch ^ 48ll));

	return s * f ;

}

int main()

{

	int n,m;



	while(cin>>n>>m)

	{

		int k = m%n;

		int l = m/n;

		if(n==1)

		{

			cout<<m<<endl;

		}

		else if(n == 2)

		{

			if(m&1)

				cout<<1<<endl;

			else cout<<m/2<<endl;

		}

		else

		{

			if(k!=0)

			{

				int ans = 1;

				for(int i=0; i<l ; i++)

				{

					if( (k+(n-1)*i+l) % (l-i) == 0 )

					{

						ans = l-i;

						break;

					}

//					int x = i*(n-1);

//					int y = m-x;

//					int z = __gcd(y,i);

//					ans = max(ans,z);

				}

				cout<<ans<<endl;

			}

			else cout<<m/n<<endl;

		}



	}

	wtcl 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

	long long n,m,ans=0;

	scanf("%lld%lld",&n,&m);

	if(n>m)

	{

		cout<<"0"<<endl;

		return 0;

	}

	if(m%n==0)

	{

		cout<<m/n<<endl;

		return 0;

	}

	for(long long i=1;i<=m;i++)

	{

		if(m%i==0&&m/i>=n)

		ans=i;

		if(m/i<n) break;

	}

	printf("%lld",ans);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.2217607901699965x):
#include <iostream>

#include <string>

#include <stdio.h>

#include <queue>

#include <stack>

#include <string.h>

#include <algorithm>

#include <math.h>

//#include <bits/stdc++.h>

#define ll long long

#define wtcl return

using namespace std;



inline int read()

{

	ll s = 0, f = 1;

	char ch = getchar();

	for(; ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = - 1;

	for(; ch >= '0' && ch <= '9'; ch = getchar()) s = ((s << 3ll) + (s << 1ll) + (ch ^ 48ll));

	return s * f ;

}

int main()

{

	int n,m;



	while(cin>>n>>m)

	{

		int k = m%n;

		int l = m/n;

		if(n==1)

		{

			cout<<m<<endl;

		}

		else if(n == 2)

		{

			if(m&1)

				cout<<1<<endl;

			else cout<<m/2<<endl;

		}

		else

		{

			if(k!=0)

			{

				int ans = 1;

				for(int i=0; i<l ; i++)

				{

					if( (k+(n-1)*i+l) % (l-i) == 0 )

					{

						ans = l-i;

						break;

					}

//					int x = i*(n-1);

//					int y = m-x;

//					int z = __gcd(y,i);

//					ans = max(ans,z);

				}

				cout<<ans<<endl;

			}

			else cout<<m/n<<endl;

		}



	}

	wtcl 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main()

{

    ios::sync_with_stdio(false);

    int n, m, ans = -1;

    cin >> n >> m;

    for (int i = 1; i * i <= m; i++)

    {

        if (m % i == 0)

        {

            if (i <= m / n)

                ans = max(ans, i);

            if (i >= n)

                ans = max(ans, m / i);

        }

    }

    cout << ans << endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 0.9863562503563152x):
#include <iostream>

#include <string>

#include <stdio.h>

#include <queue>

#include <stack>

#include <string.h>

#include <algorithm>

#include <math.h>

//#include <bits/stdc++.h>

#define ll long long

#define wtcl return

using namespace std;



inline int read()

{

	ll s = 0, f = 1;

	char ch = getchar();

	for(; ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = - 1;

	for(; ch >= '0' && ch <= '9'; ch = getchar()) s = ((s << 3ll) + (s << 1ll) + (ch ^ 48ll));

	return s * f ;

}

int main()

{

	int n,m;



	while(cin>>n>>m)

	{

		int k = m%n;

		int l = m/n;

		if(n==1)

		{

			cout<<m<<endl;

		}

		else if(n == 2)

		{

			if(m&1)

				cout<<1<<endl;

			else cout<<m/2<<endl;

		}

		else

		{

			if(k!=0)

			{

				int ans = 1;

				for(int i=0; i<l ; i++)

				{

					if( (k+(n-1)*i+l) % (l-i) == 0 )

					{

						ans = l-i;

						break;

					}

//					int x = i*(n-1);

//					int y = m-x;

//					int z = __gcd(y,i);

//					ans = max(ans,z);

				}

				cout<<ans<<endl;

			}

			else cout<<m/n<<endl;

		}



	}

	wtcl 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;



vector<ll>div(ll n)

{

    ll i,a,b;

    vector<ll>res;

    for(i=1; i<=sqrt(n); i++)

    {

        if(n%i==0)

        {

            a=n/i;

            res.push_back(i);

            if(a!=i)res.push_back(a);

        }

    }

    sort(res.begin(),res.end());



    return res;

}



int main()

{



    ll n,a,b,i,m;

    cin >> n >> m;

    vector<ll>v=div(m);

    reverse(v.begin(),v.end());

    for(i=0; i<v.size(); i++)

    {

        a=v[i];

        b=m/a;

        if(b>=n)

        {

            cout << a << "\n";

            return 0;

        }

    }

    cout << 1 << "\n";







    return 0;

}




// Faster C++ solution for the same problem (measured speedup: 0.9676262687860858x):
#include <iostream>

#include <string>

#include <stdio.h>

#include <queue>

#include <stack>

#include <string.h>

#include <algorithm>

#include <math.h>

//#include <bits/stdc++.h>

#define ll long long

#define wtcl return

using namespace std;



inline int read()

{

	ll s = 0, f = 1;

	char ch = getchar();

	for(; ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = - 1;

	for(; ch >= '0' && ch <= '9'; ch = getchar()) s = ((s << 3ll) + (s << 1ll) + (ch ^ 48ll));

	return s * f ;

}

int main()

{

	int n,m;



	while(cin>>n>>m)

	{

		int k = m%n;

		int l = m/n;

		if(n==1)

		{

			cout<<m<<endl;

		}

		else if(n == 2)

		{

			if(m&1)

				cout<<1<<endl;

			else cout<<m/2<<endl;

		}

		else

		{

			if(k!=0)

			{

				int ans = 1;

				for(int i=0; i<l ; i++)

				{

					if( (k+(n-1)*i+l) % (l-i) == 0 )

					{

						ans = l-i;

						break;

					}

//					int x = i*(n-1);

//					int y = m-x;

//					int z = __gcd(y,i);

//					ans = max(ans,z);

				}

				cout<<ans<<endl;

			}

			else cout<<m/n<<endl;

		}



	}

	wtcl 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



int n,m;

vector <int> veca;



int main()

{

    cin >> n >> m;

    for (int i=1;i<=sqrt(m);i++)

    {

        if (m%i==0)

        {

            if ((m/(m/i))>=n)

                veca.push_back(m/i);

            if ((m/i)>=n)

                veca.push_back(i);

        }

    }

    sort(veca.begin(),veca.end());

    cout << veca[veca.size()-1] << endl;

}


// Faster C++ solution for the same problem (measured speedup: 1.0074775682862043x):
#include <iostream>

#include <string>

#include <stdio.h>

#include <queue>

#include <stack>

#include <string.h>

#include <algorithm>

#include <math.h>

//#include <bits/stdc++.h>

#define ll long long

#define wtcl return

using namespace std;



inline int read()

{

	ll s = 0, f = 1;

	char ch = getchar();

	for(; ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = - 1;

	for(; ch >= '0' && ch <= '9'; ch = getchar()) s = ((s << 3ll) + (s << 1ll) + (ch ^ 48ll));

	return s * f ;

}

int main()

{

	int n,m;



	while(cin>>n>>m)

	{

		int k = m%n;

		int l = m/n;

		if(n==1)

		{

			cout<<m<<endl;

		}

		else if(n == 2)

		{

			if(m&1)

				cout<<1<<endl;

			else cout<<m/2<<endl;

		}

		else

		{

			if(k!=0)

			{

				int ans = 1;

				for(int i=0; i<l ; i++)

				{

					if( (k+(n-1)*i+l) % (l-i) == 0 )

					{

						ans = l-i;

						break;

					}

//					int x = i*(n-1);

//					int y = m-x;

//					int z = __gcd(y,i);

//					ans = max(ans,z);

				}

				cout<<ans<<endl;

			}

			else cout<<m/n<<endl;

		}



	}

	wtcl 0;

}
// Slower C++ solution:
#include<iostream>



using namespace std;



int main(){

	int n, m, ans = 1;

	cin >> n >> m;

	if(n == 1){

		ans = m;

	}else{

		for(int i = 2; n * i <= m; i++){

			if((m - n * i) % i == 0){

				ans = i;

			}

		}

	}

	cout << ans << endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.3523038942990484x):
#include<iostream>



using namespace std;



int main(){

	int n, m, ans = 1;

	cin >> n >> m;

	for(int i = m / n; i >= 1; i--){

		if((m - n * i) % i == 0){

			ans = i;

			break;

		}

	}

	cout << ans << endl;

	return 0;

}
// Slower C++ solution:


#include <algorithm>

#include <bitset>

#include <cmath>

#include <cstdio>

#include <cstdlib>

#include <ctime>

#include <deque>

#include <functional>

#include <iomanip>

#include <iostream>

#include <list>

#include <map>

#include <numeric>

#include <queue>

#include <set>

#include <sstream>

#include <stack>

#include <utility>

#include <vector>





using namespace std;



int main(){



	long N, M, max;



	long ans = 1;



	cin >> N >> M;



	if (N == 1) {

		cout << M << endl;

		return 0;

	}

	max = (M / N);



	for(long i = 2; i <= max; i++){

		if(M % i == 0) ans = i;

	}



	cout << ans << endl;



	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.356399055154242x):


#include <algorithm>

#include <bitset>

#include <cmath>

#include <cstdio>

#include <cstdlib>

#include <ctime>

#include <deque>

#include <functional>

#include <iomanip>

#include <iostream>

#include <list>

#include <map>

#include <numeric>

#include <queue>

#include <set>

#include <sstream>

#include <stack>

#include <utility>

#include <vector>





using namespace std;



int main(){



	long N, M, max;



	long ans = 1;



	cin >> N >> M;



	max = M/N;



	for(long i = max; i > 0; i--){

		if(M % i == 0){

		 	ans = i;

			break;

		}

	}



	cout << ans << endl;



	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

typedef long long ll;





std::vector<ll> enum_div(ll n);



int main() {



    ll N, M;



    cin >> N >> M;



    vector<ll> v = enum_div(M);



    sort(v.begin(), v.end(), greater<ll>());



    ll ans = 1;



    for (ll i = 0; i < v.size(); i++) {

        if (v[i] * N <= M) {

            ans = v[i];

            break;

        }

        

    }





    cout << ans << '\n';



}



std::vector<ll> enum_div(ll n)//nの約数を列挙

{

    vector<ll> ret;

    for (ll i = 1; i * i <= n; i++) {



        if (n % i == 0) {



            ret.push_back(i);



            if (i * i != n) {

                ret.push_back(n / i);

            }

        }

    }

    

    return ret;

}


// Faster C++ solution for the same problem (measured speedup: 0.9629577817710813x):
#include <iostream>

int main(){

    int N,M,i;std::cin>>N>>M;

    for (i=M/N;i>=1;i--){if((M-i*N)%i==0){std::cout<<i<<'\n';break;}}}
// Slower C++ solution:
#include <iostream>

using namespace std;









int main() {



    int N, M;



    cin >> N >> M;



    int start = M / N;

    int ans = 1;



    for (int i = start; i >= 1; i--) {

        

        if ( (M - i * N) % i == 0 ) {

            ans = i;

            break;

        }

    }



    cout << ans << '\n';

}




// Faster C++ solution for the same problem (measured speedup: 2.5883716418795024x):
#include <cstdio>

int main(){int N,M,i;scanf("%d%d",&N,&M);for (i=M/N;i>=1;i--){if((M-i*N)%i==0){printf("%d\n",i);break;}}}
// Slower C++ solution:
#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

typedef long long ll;





std::vector<ll> enum_div(ll n);



int main() {



    ll N, M;



    cin >> N >> M;



    vector<ll> v = enum_div(M);



    sort(v.begin(), v.end(), greater<ll>());



    ll ans = 1;



    for (ll i = 0; i < v.size(); i++) {

        if (v[i] * N <= M) {

            ans = v[i];

            break;

        }

        

    }





    cout << ans << '\n';



}



std::vector<ll> enum_div(ll n)//nの約数を列挙

{

    vector<ll> ret;

    for (ll i = 1; i * i <= n; i++) {



        if (n % i == 0) {



            ret.push_back(i);



            if (i * i != n) {

                ret.push_back(n / i);

            }

        }

    }

    

    return ret;

}


// Faster C++ solution for the same problem (measured speedup: 2.492454551013555x):
#include <cstdio>

int main(){int N,M,i;scanf("%d%d",&N,&M);for (i=M/N;i>=1;i--){if((M-i*N)%i==0){printf("%d\n",i);break;}}}
// Slower C++ solution:
#include <iostream>

int main(){

    int N,M,i;std::cin>>N>>M;

    for (i=M/N;i>=1;i--){if((M-i*N)%i==0){std::cout<<i<<'\n';break;}}}

// Faster C++ solution for the same problem (measured speedup: 2.588332114030387x):
#include <cstdio>

int main(){int N,M,i;scanf("%d%d",&N,&M);for (i=M/N;i>=1;i--){if((M-i*N)%i==0){printf("%d\n",i);break;}}}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define int long long

signed main(void){

    int n,m; cin>>n>>m;

    if(n==1) {cout<<m<<endl; return 0;}

    int x = m/n;

    int ans =0;

    for(int i=1;i<=x;i++){

       if(m%i==0) ans = i;

    }

    cout<<ans<<endl;

    

}


// Faster C++ solution for the same problem (measured speedup: 1.3566300970832086x):
#include <bits/stdc++.h>

using namespace std;

#define int long long

signed main(void){

    int n,m; cin>>n>>m;

    if(n==1) {cout<<m<<endl; return 0;}

    int x = m/n;

    for(int i=x;i>0;i--){

       if(m%i==0) {cout<<i<<endl; return 0;}

    }

}
// Slower C++ solution:
#include <algorithm>

#include <iostream>

#include <vector>

using namespace std;



vector<long long> enum_divisors(long long n) {

    vector<long long> res;

    for (long long i = 1LL; i * i <= n; i++) {

        if (n % i == 0) {

            res.emplace_back(i);

            if (i != n / i) res.emplace_back(n / i);

        }

    }

    sort(res.begin(), res.end());

    return res;

}



int main() {

    long long N, M; cin >> N >> M;

    long long ans = 1;

    for (long long d: enum_divisors(M)) {

        if (d * N <= M) ans = max(ans, d);

    }

    cout << ans << endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 0.9788038037521577x):
#include <algorithm>

#include <iostream>

#include <vector>

using namespace std;



int main() {

    int n, m; cin >> n >> m;

    for (int g = m / n; g > 0; g--) {

        if (m % g == 0) {

            cout << g << endl;

            return 0;

        }

    }

}
// Slower C++ solution:
#include <bits/stdc++.h>



#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)

#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)

#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)

#define all(c) (c).begin(),(c).end()

#define sz(v) (int)(v).size()



using namespace std;

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;

const int mod = (int)1e9 + 7;

void dbg(){ cerr << "\n"; }  

template <typename T,typename ...T2>

void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main(){

	ll n,m, ans = 1;

	cin >>n >>m;

	

	for(ll i=1; i*i <=m; i++){

		if(m % i != 0) continue;

		

		if(i*n <=m)     ans = max(ans, i);

		if((m/i)*n <=m) ans = max(ans, m/i);

		

	}

	cout << ans <<"\n";

}


// Faster C++ solution for the same problem (measured speedup: 0.9067664332777317x):
#include <bits/stdc++.h>



using namespace std;

 

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)

#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)

#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)

#define all(c) (c).begin(),(c).end()

#define sz(v) (int)(v).size()



typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;

const int MD = 1e9+7; typedef vector<ll> VL;



void dbg(){ cerr << "\n"; }  

template <typename T,typename ...T2>

void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }





int main()

{

	

	cin.tie(0); ios_base::sync_with_stdio(false);

	int n, m;

	cin >>n >>m;

	

	int p= m/n;

	

	repr(i, p, 1){

		ll x = m - (i * (n-1));

		if(x % i ==0){

			cout << i <<"\n";  return 0;

		}

	

	}

	

	return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;



int main() {

	int n;

	int m;

	cin >> n >> m;



	int ans = 1;

	for (int i = n; i <= m / 2; ++i) {

		if (m%i == 0) {

			ans = m / i;

			break;

		}

	}

	cout << ans << endl;



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.4036534852730547x):
#include <bits/stdc++.h>

using namespace std;



int main(){

  int N,M;

  cin>>N>>M;

  for(int i=M/N;i>=1;i--){

    if(M%i == 0){

      if(M/i >= N){

        cout<<i<<endl;

        break;

      }

    }

  }

  return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);



    int N, M; cin >> N >> M;

    int ans = 0;

    for (int i = 1; i <= max(N, (int)sqrt(M) + 1); ++i) {

        if (M % i == 0) {

            if (i >= N) ans = max(ans, M / i);

            if (M / i >= N) ans = max(ans, i);

        }

    }

    cout << ans << endl;



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1446406649332972x):
#include <bits/stdc++.h>

using namespace std;



int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);



    int N, M; cin >> N >> M;

    int ans = 0;

    for (int i = 1; i <= N || i * i <= M; ++i) {

        if (M % i == 0) {

            if (i >= N) ans = max(ans, M / i);

            if (M / i >= N) ans = max(ans, i);

        }

    }

    cout << ans << endl;



    return 0;

}
// Slower C++ solution:


#include<iostream>



#include<cmath>



using namespace std;



int main()



{



	int n,m;



	cin>>n>>m;



	for(int i=m/n;i>=1;i--)



	{



		if(m%i==0)



		{



			int t=m/i;



			if(t>=n)



			{



				cout<<i<<endl;



				break;



			}



		}



	}



}


// Faster C++ solution for the same problem (measured speedup: 2.5536946060522046x):
#include <stdio.h>

#include <math.h>

int main()

{	int n,m,t;

	scanf("%d%d",&n,&m);

	if(m-n<10000000)

	{

		while(m%n) n++;

		printf("%d",m/n);

	}

	else

	{

		t=m/n;

		while(m%t) t--;

		printf("%d",t);

	}

	return 0;

}
// Slower C++ solution:


#include<iostream>



#include<cmath>



using namespace std;



int main()



{



	int n,m;



	cin>>n>>m;



	for(int i=m/n;i>=1;i--)



	{



		if(m%i==0)



		{



			int t=m/i;



			if(t>=n)



			{



				cout<<i<<endl;



				break;



			}



		}



	}



}


// Faster C++ solution for the same problem (measured speedup: 1.6012235982138556x):
#include<algorithm>

#include<cstdio>

#include<cmath>

using namespace std;

typedef long long ll;

int main()

{

    ll n;

    ll m;

    scanf("%lld%lld",&n,&m);

    ll maxl=m/n;

    if(m%n==0)

    {

        printf("%lld\n",m/n);

        return 0;

    }

    ll minl=1;

    ll mid=(maxl+minl)/2;

    ll out=0;

    for(int i=minl;i<=maxl;++i)

    {

        if(m%i==0)

            if(out<i)

            out=i;

    }

    printf("%lld\n",out);

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

long long int m,n,min1;

unsigned long long int f[100010]={0,1};

int main()

{

	cin>>n>>m;

	min1=m/n;

	for(long long int i=min1;i>=1;i--)

	{

		if(m%i!=0) continue;

		if(m/i>=n)

		{

			cout<<i;

			return 0;

		}

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.598466215775339x):
#include<algorithm>

#include<cstdio>

#include<cmath>

using namespace std;

typedef long long ll;

int main()

{

    ll n;

    ll m;

    scanf("%lld%lld",&n,&m);

    ll maxl=m/n;

    if(m%n==0)

    {

        printf("%lld\n",m/n);

        return 0;

    }

    ll minl=1;

    ll mid=(maxl+minl)/2;

    ll out=0;

    for(int i=minl;i<=maxl;++i)

    {

        if(m%i==0)

            if(out<i)

            out=i;

    }

    printf("%lld\n",out);

}
// Slower C++ solution:
#include <cstdio>

#include <cstring>

#include <cmath>

#include <iostream> 

using namespace std;

int n, m, tmp, mm;

int main(){

	

	scanf("%d%d", &n, &m);

	mm = (int)sqrt(double(m));

	tmp = 0x7fffffff;

	for (int i=1; i<=mm; i++){

		if (m % i == 0){

			if (i >= n && i < tmp) tmp = i;

			if ((m / i) >= n && (m / i) < tmp) tmp = m / i; 

		}

	}

	printf("%d", m / tmp);

} 

// Faster C++ solution for the same problem (measured speedup: 1.4959528685736942x):
#include<algorithm>

#include<cstdio>

#include<cmath>

using namespace std;

typedef long long ll;

int main()

{

    ll n;

    ll m;

    scanf("%lld%lld",&n,&m);

    ll maxl=m/n;

    if(m%n==0)

    {

        printf("%lld\n",m/n);

        return 0;

    }

    ll minl=1;

    ll mid=(maxl+minl)/2;

    ll out=0;

    for(int i=minl;i<=maxl;++i)

    {

        if(m%i==0)

            if(out<i)

            out=i;

    }

    printf("%lld\n",out);

}
// Slower C++ solution:
#include <cstdio>

#include <cstring>

#include <cmath>

#include <iostream> 

using namespace std;

int n, m, tmp, mm;

int main(){

	

	scanf("%d%d", &n, &m);

	mm = (int)sqrt(double(m));

	tmp = 0x7fffffff;

	for (int i=1; i<=mm; i++){

		if (m % i == 0){

			if (i >= n && i < tmp) tmp = i;

			if ((m / i) >= n && (m / i) < tmp) tmp = m / i; 

		}

	}

	printf("%d", m / tmp);

} 

// Faster C++ solution for the same problem (measured speedup: 0.9431700472088276x):
//antaji dhil martasi. vul hoile amar kono dosh nai

#include<bits/stdc++.h>

using namespace std;

int main()

{

    int n, m;

    scanf("%d %d", &n, &m);

    int i = m/n;

    while(i > 1)

    {

        if(m%i == 0)

            break;

        i--;

    }

    printf("%d", i);

}
// Slower C++ solution:
#pragma GCC optimize(2)

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()

{

	ll i,ans=0,n,m;

	scanf("%lld%lld",&n,&m);

	for(i=1;i*i<=m;i++) if(m%i==0)

	{

		if(n*i<=m) ans=max(ans,i);

		if(n<=i) ans=max(ans,m/i);

	}

	cout<<ans<<endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 0.9703704910420488x):
//antaji dhil martasi. vul hoile amar kono dosh nai

#include<bits/stdc++.h>

using namespace std;

int main()

{

    int n, m;

    scanf("%d %d", &n, &m);

    int i = m/n;

    while(i > 1)

    {

        if(m%i == 0)

            break;

        i--;

    }

    printf("%d", i);

}