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