#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { long long n; cin >> n; int c = __builtin_popcountll(n); cout << (1LL << c) - 2 << endl; }