#include <iostream>

using namespace std;

int pro = 1, limit = 1;

void fact(int a)
{
    while (pro < a)
    {
        pro *= limit;
        limit++;
    }

    limit--;
    pro /= limit;
}

int main()
{
    int n;

    cin >> n;

    fact(n);

    ///cout << pro << " " << limit << endl;

    int m = n / pro;

    if (n % pro == 0)
    {
        m--;
    }

    cout << 1 + m * pro << endl;

    return 0;
}
/**
100000 - 80641
 99999 - 80641
 12345 - 10081
 23432 - 20161
 721 - 721
**/
