#include using namespace std; int btc(int64_t n) { int r = 0; for (; n; n >>= 1) { if (n & 1) { r++; } } return r; } int64_t pow(int64_t a, int n) { int64_t r = 1; for (; n; n >>= 1) { if (n & 1) { r *= a; } a *= a; } return r; } int main() { int64_t n; cin >> n; int64_t puni = pow(2, btc(n)); cout << n - puni + 1 << endl; return 0; }