#include <bits/stdc++.h>
using namespace std;
int l, r;
inline int divs(int d) { return (r / d) - ((l - 1) / d); }
int main() {
  ios_base::sync_with_stdio(false);
  cin >> l >> r;
  set<int> divisors;
  for (int i = int(2); i < int(sqrt(l) + 3); i++) {
    if (l % i == 0) {
      divisors.insert(i);
      divisors.insert(l / i);
    }
  }
  divisors.insert(l);
  for (int i = int(2); i < int(sqrt(r) + 3); i++) {
    if (r % i == 0) {
      divisors.insert(i);
      divisors.insert(r / i);
    }
  }
  divisors.insert(r);
  divisors.erase(1);
  int size = r - l + 1;
  if (size > 1 or (l % 2 == 0)) {
    divisors.insert(2);
  }
  int cont = 0;
  int ans = 0;
  for (int d : divisors) {
    int next = divs(d);
    if (next >= cont) {
      cont = next;
      ans = d;
    }
  }
  cout << ans << "\n";
  return 0;
}
