#include using namespace std; int main(void) { cin.tie(0); ios::sync_with_stdio(false); long long int N; cin >> N; int cnt = 0; long long int temp = N; while(temp > 0) { if(temp%2==1) { cnt++; } temp/=2; } long long int res = (1LL << cnt) - 1; res = N - res; cout << res << '\n'; return 0; }