#include #define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++) using namespace std; typedef long long ll; int main(void) { ll N; cin >> N; ll cnt = 0; REP(i, 0, 63) if(N & (1LL << i)) cnt++; cout << N + 1 - pow(2, cnt) << endl; }