#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  for (int gcd = M / N; gcd >= 1; gcd--) {
    if ((M - (gcd * N)) % gcd == 0) {
      cout << gcd << endl;
      return 0;
    }
  }
}
