#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,t,s=0,a,i;
cin>>n;
t=n;
while(t!=0){
t/=2;
s+=1;
}
a=pow(2,s);
i=pow(2,s-1);
if(n-i<=a-n) cout<<i;
else cout<<a;
return 0;
}
/**************************************************************
Problem: 1075
User: ccf
Language: C++
Result: Accepted
Time:14 ms
Memory:2324 kb
****************************************************************/