long f(long n){ long r=1; while(n){ r<<=n&1; n>>=1; } return r; } main(){ long n,i; scanf("%ld",&n); printf("%ld\n",n+1-f(n)); }