#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll kMod = (ll)1e9 + 7;
int main(int argc, char **argv) {
  ios::sync_with_stdio(false);
  srand(time(0));
  ll l, r;
  cin >> l >> r;
  ll ans = -1, cnt = -1;
  for (ll i = 2; i <= ceil(sqrt(r)); ++i) {
    ll a = l % i == 0 ? l : min(((l / i) + 1) * i, r);
    if (a % i != 0) continue;
    if ((r - a) / i > cnt) {
      ans = i;
      cnt = (r - a) / i;
    }
  }
  cout << (ans > 1 ? ans : r) << endl;
}
