#include <iostream>
using namespace std;
#define LL long long

#include <cmath>
void _140() {
    int n;
    cin >> n;
    int b[100];
    LL sum = 0;
    for (int i = 0; i < n - 1; ++i) {
        cin >> b[i];
        if (i == 0) {
            sum += b[i];
        } else {
            sum += min(b[i - 1], b[i]);
        }
    }
    sum += b[n - 2];

    cout << sum << endl;
}

void _141() {
    int n, k, q;
    cin >> n >> k >> q;
    int a[100000];
    int point[100000] = {0};
    for (int i = 0; i < q; ++i) {
        cin >> a[i];
        point[a[i] - 1]++;
    }

    for (int i = 0; i < n; ++i) {
        if (k + point[i] - q > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
 }

#include <vector>
#include <algorithm>
void _142() {
    int n;
    cin >> n;
    int a;
    vector<pair<int, int> > list;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        list.push_back(make_pair(a, i + 1));
    }

    sort(list.begin(), list.end());
    for (int i = 0; i < n; ++i) {
        cout << list[i].second;
        if (i == n - 1)
            cout << endl;
        else
            cout << " ";
    }
}

#include <string>
void _143() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    char prev_color = s[0];
    int count = 1;
    for (int i = 1; i < s.size(); ++i) {
        if (s[i] != prev_color) {
            count++;
            prev_color = s[i];
        }
    }
    cout << count << endl;
}

void _144() {
    LL n;
    cin >> n;
    LL m = floor(sqrt(n));

    LL result = 0;
    for (LL i = m; m > 0; --i) {
        if (n % i == 0) {
            result = i + n / i - 2;
            break;
        }
    }
    cout << result << endl;
}

#include <iomanip>
#include <cmath>
void _145() {
    int n;
    cin >> n;
    int x[8], y[8];
    vector<int> points;
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
        points.push_back(i);
    }

    int curr_x, curr_y;
    double sum = 0;
    int count = 0;
    do {
        double distance = 0;
        curr_x = x[points[0]];
        curr_y = y[points[0]];
        // cout << points[0] << endl;
        for (int i = 1; i < n; ++i) {
            // cout << curr_x << " " << curr_y << endl;
            // cout << x[points[i]] << " " << y[points[i]] << endl;
            // cout << (pow(x[points[i]] - curr_x, 2)) << " " << ((y[points[i]] - curr_y)) << endl;
            // cout << ((x[points[i]] - curr_x) ^ 2 + (y[points[i]] - curr_y) ^ 2) << endl;
            distance += sqrt(pow(x[points[i]] - curr_x, 2) + pow(y[points[i]] - curr_y, 2));
            curr_x = x[points[i]];
            curr_y = y[points[i]];
            // cout << distance << endl;
            // cout << endl;
        }
        // cout << distance << endl;
        sum += distance;
        count++;
    } while (next_permutation(points.begin(), points.end()));

    cout << fixed << setprecision(10);
    cout << sum / count << endl;

}

void _146() {
    LL a, b, x;
    cin >> a >> b >> x;

    LL n = 0;
    int order = 0;
    for (int i = 1; ; ++i) {
        if (a * pow(10, i) + b * i > x){
            order = i;
            break;
        }
    }

    if (order == 0) {
        cout << 0 << endl;
        return;
    }

    n = floor((x - b * order) / a);
    if (n > pow(10, 9)) {
        n = pow(10, 9);
    }
    cout << n;
}

#include <bitset>
void _147() {
    int n;
    cin >> n;
    int a[15];
    vector<pair<int, int> > answers[15];
    int x, y;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        for (int j = 0; j < a[i]; ++j) {
            cin >> x >> y;
            answers[i].push_back(make_pair(x, y));
        }
    }

    int max_honest_count = 0;
    int honest_count = 0;
    bool conflict = false;
    for (int i = 0; i < pow(2, n); ++i) {
        conflict = false;
        // cout << "candidate : ";
        // cout << std::bitset<15>(i);
        // cout << endl;
        honest_count = 0;
        for (int j = 0; j < n; ++j) {
            // cout << (i >> j & 1) << endl;
            // cout << i << " " << j << endl;
            if ((i >> j) & 1) {
                // cout << "number of answers is " << answers[j].size() << endl;
                for (int k = 0; k < answers[j].size(); ++k) {
                    // cout << answers[j][k].first << " " << answers[j][k].second << endl;
                    // cout << (i >> (answers[j][k].first - 1) & 1) << endl;
                    if ((i >> (answers[j][k].first - 1) & 1) != answers[j][k].second) {
                        conflict = true;
                        // cout << "conflict" << endl;
                        break;
                    }
                }
                if (conflict) {
                    break;
                }
                // cout << j << " is honest" << endl;
                honest_count++;
            }
        }
        if ((conflict == false) && (honest_count > max_honest_count)) {
            max_honest_count = honest_count;
            // cout << "max : " << max_honest_count << endl;
        }
    }

    cout << max_honest_count << endl;
}

#include <numeric>
#include <limits>
#include <type_traits>
void _148() { 
    LL a, b;
    cin >> a >> b;
    cout << a * b / __gcd(a, b) << endl;
}

void _149() {
    LL x;
    cin >> x;

    LL result = x;
    bool sosuu;
    for (; ; ++result) {
        // cout << result << endl;
        sosuu = true;
        for (int i = 2; i < result / 2; ++i) {
            if (result % i == 0) {
                sosuu = false; 
                break;
            }
        }
        if (sosuu) {
            break;
        }
    }
    cout << result << endl;
}

int main()
{
    _149();

    return 0;
}



Measured memory_bytes: 256