#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;

vector<ll> calc_divisor(ll n) {
    vector<ll> res;
    for (ll i = 1LL; i*i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            ll j = n / i;
            if (j != i) res.push_back(j);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

ll N, M;

int main() {
    cin >> N >> M;
    vector<ll> v = calc_divisor(M);

    reverse(v.begin(), v.end());
    ll ans = 0;
    rep(i, v.size()) {
        // cout << v[i] << endl;
        if (M % v[i] == 0) {
            ll tmp = M / v[i];
            if (tmp >= N) {
                ans = v[i];
                break;
            }
        }
    }
    cout << ans << endl;
}
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int N, M; cin >> N >> M;
  int MAX = M/N;
  for (int i=MAX;i>=1;i--){
    if ((M - i*N)%i==0) {
      cout << i << endl;
      return 0;
    }
  }
  

  // cout << fixed << setprecision(10);
  
  return 0;
}
