#include using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); unsigned long long N; cin >> N; cout << N - (1LL << popcount(N)) + 1 << "\n"; }