#include<iostream>
#include<algorithm>
using namespace std;
int mas[100000];
int main()
{
    int n, ng = 0;

    cin >> n;

    for(int i = 0; i < n; i++)
    {
        mas[i] = i + 1;
    }

    int zacherk = 2, prev;

    while(true)
    {
        ng = 0;

        for(int i = 1; i < n; i++)
        {
            if(i % zacherk != 0)
            {
                mas[i] = 100001;
            }
        }

        sort(mas, mas + n);

        for(int i = 0; i < n; i++)
        {
            if(mas[i] > ng && mas[i] != 100001)
            {
                ng = mas[i];
            }
        }

        if(mas[1] == 100001)
        {
            cout << prev;
            return 0;
        }

        prev = ng;

        zacherk++;
    }



    return 0;
}
