#include<bits/stdc++.h>
using namespace std;
vector<int> a, b;
void printA(){
    for(long long i = 0; i < a.size(); i++){
        cout<<a[i]<<" ";
    }
    cout<<endl;
}

void printB(){
    for(long long i = 0; i < b.size(); i++){
        cout<<b[i]<<" ";
    }
    cout<<endl;
}
int main(){
    long long n;
    cin>>n;
    for(long long i = 1;i <= n; i++){
        a.push_back(i);
    }
    long long tek = 2;
    bool ali = true;
    long long lastNum = 0;
    while(true){
        if(ali){
            b.push_back(1);
            for(long long i = tek; i < a.size(); i+=tek){
                b.push_back(a[i]);
            }
            if(b.size() > 1){
                lastNum = b.back();
            }else{
                cout<<lastNum<<endl;
                return 0;
            }
            ali = false;
            a.clear();
            ///printB();
        }else{
            a.push_back(1);
            for(long long i = tek; i < b.size(); i+=tek){
                a.push_back(b[i]);

            }
            if(a.size() > 1){
                lastNum = a.back();
            }else{
                cout<<lastNum<<endl;
                return 0;
            }
            ali = true;
            b.clear();
            ///printA();
        }
        tek++;
    }

}
