#include <stdio.h>
int main()
{
long a,b,c,d,e;
scanf("%ld",&a);
d=a;
b=0;
while(d>2)
{
d=d/2;
b=b+1;
}
b=b-1;
d=2;
for(c=1;c<=b;c++)
{
d=d*2;
}
b=d*2;
c=b-a;
e=a-d;
if(c<e) printf("%ld\n",b);
else printf("%ld\n",d);
return 0;
}