/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int64_t N, M;
  cin >> N >> M;
  for (int64_t g = M / N; g >= 1; --g) {
    if (M % g == 0 && M / g >= N) {
      cout << g << endl;
      return 0;
    }
  }
  cout << 1 << endl;
  return 0;
}

#include<bits/stdc++.h>
using namespace std;

vector < int > v;

bool check(int n, int m, int mid){

    int x=(m-mid);
    long long int y=(n-1)*1LL*mid;
    return (x>=y && x%mid==0);
    ///return (m/mid>=n && m%mid==0);
}

int cal(int n, int m){
    int ans=0;
    for(int i=1; i*i<=m; i++){
        if(m%i==0){
             if(check(n,m,i))ans=max(ans,i);
             if(check(n,m,m/i))ans=max(ans,m/i);
        }
    }
    return ans;
}

int main(){

    int n,m;
    cin>>n>>m;
    int ans=cal(n,m);
    cout<<ans<<endl;
    return 0;
}
