#include <bits/stdc++.h>
using namespace std;

int numbers[100001];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int totalSize;
    int maxNumber=0;
    cin >> totalSize;

    int nowSkip=2;
    int nowPlus=3;

    for(int nowNumber=1; nowNumber<=totalSize; nowNumber++)
    {
        numbers[nowNumber-1]=nowNumber;
    }

    while(true)
    {
        if(nowSkip>=totalSize)
        {
            break;
        }

        if(nowSkip*nowPlus>=totalSize)
        {
            for(int index=0; index<totalSize; index+=nowSkip)
            {
                maxNumber=max(maxNumber, numbers[index]);
            }
        }

        nowSkip=nowSkip*nowPlus;
        nowPlus++;
    }

    cout << maxNumber;
    return 0;
}
