main(){long n;scanf("%ld",&n);printf("%ld",n-(1LL<<__builtin_popcountll(n)));}