#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

void ALLIN1_NUMBER(vector<ll>& V)
{
    for(auto& x : V)
    {
        cin >> x;
    }
}

template<class T>
void OUT0(T N)
{
    cout << N << endl;
}

static const double pi = acos(-1.0);

double Cos(double D)
{
    return cos(pi/180 * D);
}

vector<ll> Divs(ll N)
{
    map<ll,ll> ret_map;
    for(ll i=1;i*i<=N;i++)
    {
        if(N%i==0)
        {
            ret_map[i]++;
            ret_map[N/i]++;
        }
    }
    vector<ll> ret_vec;
    for(auto x : ret_map)
    {
        ret_vec.push_back(x.first);
    }
    return ret_vec;
}

ll Ans(ll N, ll M, vector<ll> div)
{
    sort(ALL(div),greater<ll>());
    for(auto x : div)
    {
        if(N * x <= M) return x;
    }
}

int main()
{
    ll N,M;
    cin >> N >> M;

    OUT0(Ans(N,M,Divs(M)));

    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
    int n, m;
    cin>>n>>m;
    if(n==1){
        cout<<m;
        return;
    }
    int mx = 0;
    for(int i = 2; i*i <= m; i++){
        if(m%i==0){
            if(m>=n*i)mx=max(mx, i);
            if(i>=n)mx=max(mx, m/i);
        }
    }   
    cout<<(mx>0?mx:1);
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}