#include <iostream>


using namespace std;
int main(){
    int n;
    cin>>n;
    int k=1;
    while(1){
        if(n==1){
            cout<<"0"<<endl;
            break;
        }
        if(k*2>n){
            cout<<k<<endl;
            break;
        }
        else k=k*2;
    }
    
    return 0;
}
