#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#pragma GCC optimize "trapv"
#endif

#include <bits/stdc++.h>
using namespace std;
#define fast \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL); \
 cout << setprecision(12) << fixed;
#define ll long long int
#define line cout << endl;
#define all(x) x.begin(), x.end()
#define pb emplace_back
#define mp make_pair
#define I emplace
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define maxPQi priority_queue<int>
#define minPQi priority_queue<int, vector<int>, greater<int>>

const int MAXN = 1000002;
const int MOD = 1000000007;
const int MOD2 = 998244353;
const ll INF = 1e18L;

// TEMPLATES
// cin >> pair<T1, T2>
template <typename T1, typename T2>
istream &operator>>(istream &istream, pair<T1, T2> &p) {
  istream >> p.first >> p.second;
  return istream;
}
// cin >> vector<T>
template <typename T> istream &operator>>(istream &istream, vector<T> &v) {
  for (auto &it : v)
    cin >> it;
  return istream;
}
// cout << pair<T1, T2>
template <typename T1, typename T2>
ostream &operator<<(ostream &ostream, const pair<T1, T2> &p) {
  ostream << p.first << " " << p.second;
  return ostream;
}
// cout << vector<T>
template <typename T>
ostream &operator<<(ostream &ostream, const vector<T> &c) {
  for (auto &it : c)
    cout << it << " ";
  return ostream;
}
// Debugging
template <typename T> void DEB(T &&t) {
#ifndef ONLINE_JUDGE
  cout << t << "\n";
#endif
}
template <typename T, typename... Args> void DEB(T &&t, Args &&... args) {
#ifndef ONLINE_JUDGE
  cout << t << " ";
  DEB(forward<Args>(args)...);
#endif
}

const int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, 1, 0, -1, -1, 1, -1, 1};

map<ll, ll> getPF(ll n) {
  map<ll, ll> ans;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ans[i]++;
      n /= i;
    }
  }
  if (n > 1)
    ans[n]++;
  return ans;
}

ll modexp(ll n, ll p, int mod = 1e9 + 7) {
  ll ans = 1;
  n %= mod;
  while (p) {
    if (p & 1)
      ans = (ans * n) % mod;
    p >>= 1; // divide by 2
    n = (n * n) % mod;
  }
  return ans;
}

ll LCM(ll a, ll b) { return (a * b) / __gcd(a, b); }

ll fact[MAXN] = {0};
void getFactorials() {
  fact[0] = fact[1] = 1;
  for (int i = 2; i < MAXN; i++) {
    fact[i] = (fact[i - 1] * i * 1LL) % MOD;
  }
}

vector<int> primes;
void sieve(int n) {
  vector<bool> prime(n + 1, true);
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p)
        prime[i] = false;
    }
  }
  for (int p = 2; p <= n; p++)
    if (prime[p]) primes.pb(p);
}

ll ncr(ll n, ll r, int mod = 1e9 + 7) {
  if (n < r)
    return 0;
  if (r == 0)
    return 1;
  ll num = fact[n], den = (fact[n - r] * fact[r]) % mod;
  ll inv = modexp(den, mod - 2);
  return (num * inv) % mod;
}

// *** SOLVE HERE *** //
void presolve() {}

void solve(int test_case) {
  int a,b;
  cin>>a>>b;
  int ans=1,lim=b/2,diff = b-a;
  if (lim>=a) {
    cout << lim << '\n';
    return ;
  }
  for (int i = diff; i >= 1; i--) {
    int t1 = (a+i-1)/i, t2 = b/i;
    int l1 = t1*i, l2 = t2*i;
    // cout << i<<" "<<l2<<" "<<l1 << '\n';
    if (l1<=b and l2>=a and l1!=l2 ) {
      cout << i << '\n';
      return;
    }
  }
}

int main() {
  fast
  // #ifndef ONLINE_JUDGE
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt", "w", stdout);
  // #endif
  presolve();
  int t = 1;
  // cin >> t;
  for (int i = 1; i <= t; i++) {
    solve(i);
  }
  return 0;
}

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

int main(){
    int a,b;
    cin>>a>>b;
    int ans=1;
    for(int i=2;i<=b-a;i++){
        int c=ceil(a/(double) i),d=b/(double) i;
        if(d-c>0) ans=i;
    }
    cout<<ans<<endl;
}