#include using namespace std; typedef long long int64; vector< int > get_prime(int n) { vector< bool > prime( n + 1, true); if(n >= 0) prime[0] = false; if(n >= 1) prime[1] = false; for(int i = 2; i * i <= n; i++){ if(prime[i]){ for(int j = i + i; j <= n; j += i) prime[j] = false; } } vector< int > primes; for(int i = 2; i <= n; i++) { if(prime[i]) primes.push_back(i); } return(primes); } int64 L, H; int64 rec(int64 idx, int64 weight, vector< int >& prime, bool first = false) { if(idx >= prime.size() || weight > H) return(2); return(max((!first && L <= weight && weight <= H) ? weight : 2LL, max(rec(idx, weight * prime[idx], prime), rec(idx + 1, weight, prime, first)))); } int main() { vector< int > prime = get_prime(100000); cin >> L >> H; pair< int64, int64 > ret(2, 2); for(int i = 0; i < prime.size(); i++) { int val = rec(i, prime[i], prime, true); if(val != 2) ret = max(ret, {prime[i], val}); } cout << ret.second << endl; }