#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <typeinfo>
#include <climits>
#include <ctype.h>
#include <string>
#include <stack>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    int n;
    cin >> n;
    n -= 100;

    int cnt;
    FOR(i, n, n + 100){
        cnt = 0;
        FOR(j, 1, i + 1){
            if(i % j == 0) cnt += 1;
            if(cnt > 2) break;
        }
        if(cnt > 2){
            cout << i << endl;
            break;
        }
    }


    return 0;
}