#include using namespace std; namespace { typedef double real; typedef long long ll; template ostream& operator<<(ostream& os, const vector& vs) { if (vs.empty()) return os << "[]"; os << "[" << vs[0]; for (int i = 1; i < vs.size(); i++) os << " " << vs[i]; return os << "]"; } template istream& operator>>(istream& is, vector& vs) { for (auto it = vs.begin(); it != vs.end(); it++) is >> *it; return is; } ll L, H; void input() { cin >> L >> H; } const ll X = ll(1e10 + 2); const ll sqX = ll(1e5 + 10); bool isPrime[sqX]; vector primes; void init() { memset(isPrime, 1, sizeof(isPrime)); isPrime[0] = isPrime[1] = false; for (int i = 2; i < sqX; i++) { if (isPrime[i]) { primes.push_back(i); for (int j = i + i; j < sqX; j += i) { isPrime[j] = false; } } } } ll minFactor(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0) return i; } return -1; //return x; } bool C(ll x, ll y) { ll mx = minFactor(x), my = minFactor(y); if (mx == my) return mx > my; return mx > my; } ll MAX(ll x, ll y) { if (C(x, y)) return x; else return y; } ll dfs(ll lb, ll ub) { if (ub - lb == 1) { return MAX(lb, ub); } else if (ub - lb == 0) { return lb; } ll mid = (lb + ub) / 2; ll x = dfs(lb, mid); ll y = dfs(mid + 1, ub); return MAX(x, y); } void solve() { cout << dfs(L, H) << endl; } } int main() { init(); input(); solve(); return 0; }