#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x=1,y=1,k;
    cin>>k;
    n=k;
    while(n!=1){
        n/=2;
        x*=2;
    }
    y=x*2;
    if(k-x<=y-k)
    cout<<x;
    else
    cout<<y;  
    return 0;
}
/**************************************************************
	Problem: 1075
	User: lijinkai
	Language: C++
	Result: Accepted
	Time:8 ms
	Memory:2072 kb
****************************************************************/