/** * @FileName a.cpp * @Author kanpurin * @Created 2020.06.07 18:34:13 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; int bitpopcount(ll n) { int res = 0; while (n) { if (n & 1) res++; n >>= 1; } return res; } int main() { ll n;cin >> n; cout << n + 1 - (ll)pow(2,bitpopcount(n)) << endl; return 0; }