#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;
  int ans = 1;
  for (int i = 1; i <= B; i++){
    int X = (A + i - 1) / i * i + i;
    if (X <= B){
      ans = i;
    }
  }
  cout << ans << endl;
}
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin >> n;
  string s;cin >> s;
  ll res = -1;
  if(s[0] != s[s.size() - 1])res = 1;
  else{
    for(int i = 1;i < (int)(s.size() - 2);i++){
      if(s[0] != s[i] && s[i + 1] != s[s.size() - 1])res = 2;
    }
  }
  cout << res << endl;
}