#include <bits/stdc++.h> 
using namespace std; 
const int MAX_SIZE = 1e6; 
  
bool prime[MAX_SIZE + 1]; 
  
void sieve() 
{ 
  
    memset(prime, true, sizeof(prime)); 
  
    for (int p = 2; p * p <= MAX_SIZE; p++) { 
  
        if (prime[p] == true) { 
  
            for (int i = p * p; i <= MAX_SIZE; i += p) 
                prime[i] = false; 
        } 
    } 
} 
  
int main() 
{ 
   int x;
   cin >> x;
    sieve();
    int i;
    for (i = x + 1; i < MAX_SIZE; i++) { 
  
        if (prime[i] == true) 
            break;
    } 
    cout << i;
    return 0; 
} 