#include using namespace std; int main(){ long long N; cin >> N; cout << (N + 1) - (1LL << __builtin_popcountll(N)) << endl; return 0; }