#include <iostream>
using namespace std;
/*通过位运算技巧,将高位复制到所有低位*/
void fillBits01(long long n)
{
if(n<=1) {cout<<n<<endl;return ;}
//将最高位复制到所有低位
n |= n>>1;
n |= n>>2;
n |= n>>4;
n |= n>>8;
n |= n>>16;
cout<<n<<endl;
}
/*循环位移*/
void fillBits(long long n)
{
if(n<=1) {cout<<n<<endl;return ;}
//找到最高位
long long hightBits = 0;
long long temp = n;
while(temp > 1)
{
temp >>= 1;
hightBits++;
}
//构造掩码:最高位后面所有的位都为1
long long mask = (1 << (hightBits+1)) - 1;
cout<<mask<<endl;
}
int main() {
long long n;cin>>n;
fillBits01(n);
}
// 64 位输出请用 printf("%lld")