#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll n, m;
    cin >> n >> m;
    if (m % n == 0) {
        cout << m / n << endl;
        return 0;
    }
    for (ll i = m / n; i >= 1; --i) {
        if (m % i != 0) continue;
        ll rest = m - i * n;
        if (rest < 0) continue;
        if (rest % i == 0) {
            cout << i << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}

#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define append push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

int main() {
  ll n,m;
  cin >> n >> m;
  const auto &res = enum_divisors(m);
  ll ans = 0;
  for (ll i : res) {
    if (n * i <= m) ans = i;
  }
  cout << ans << endl;
}