#include <bits/stdc++.h>
using namespace std;
mt19937_64 rang(
    chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
  uniform_int_distribution<int> uid(0, lim - 1);
  return uid(rang);
}
long long mpow(long long a, long long b) {
  long long res = 1;
  a %= 1000000007;
  while (b) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
    b >>= 1;
  }
  return res;
}
long long nc2(long long x) { return (x * (x - 1)) >> 1; }
long long nc3(long long x) { return (nc2(x) * (x - 2)) / 3; }
void leftrotate(string &s, int k) {
  reverse(s.begin(), s.begin() + k);
  reverse(s.begin() + k, s.end());
  reverse(s.begin(), s.end());
}
void readarray(long long a[], long long n) {
  for (long long i = (0); i < (n); ++i) {
    scanf("%lld", &a[i]);
  }
}
void prefill(long long a[], long long n, long long val) {
  for (long long i = (0); i < (n); ++i) {
    a[i] = val;
  }
}
void solve() {
  long long a, b;
  scanf("%lld", &a);
  scanf("%lld", &b);
  if (a == b) {
    cout << a << "\n";
    return;
  }
  if (a & 1 && a + 2 == b) {
    cout << a << "\n";
    return;
  }
  cout << 2 << "\n";
}
int main() {
  auto clk1 = clock();
  int t = 1;
  while (t--) solve();
  auto clk2 = clock();
  cerr << "Time taken : " << (double)(1.0 * clk2 - clk1) / CLOCKS_PER_SEC
       << "\n";
  return 0;
}
