#include <bits/stdc++.h>
using namespace std;
int main() {
  int l, r, j, m, i = 0;
  scanf("%d%d", &l, &r);
  if (l % 2 == 0 || l != r)
    printf("2");
  else {
    m = sqrt(l);
    for (j = 3; j <= m; j += 2)
      if (l % j == 0) {
        printf("%d", j);
        i = 1;
        break;
      }
    if (i == 0) printf("%d", l);
  }
  return 0;
}
