You are a lover of bacteria. You want to raise some bacteria in a box. 

Initially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night, every bacterium in the box will split into two bacteria. You hope to see exactly *x* bacteria in the box at some moment. 

What is the minimum number of bacteria you need to put into the box across those days?
The only line containing one integer *x* (1 ≤ *x* ≤ 10<sup class="upper-index">9</sup>).
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define append push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define list(n) vector<n>
#define udict(n,m) unordered_map<n,m>
#define dict(n,m) map<n,m>
#define print(n) cout << n << endl;
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long ll;
typedef unsigned long long int  uint64;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
template <typename T> inline void write(T x)
{
    int i = 20;
    char buf[21];
    buf[10] = 0;
    buf[20] = '\n';
 
    do
    {
        buf[--i] = x % 10 + '0';
        x/= 10;
    }while(x);
    do
    {
        putchar(buf[i]);
    } while (buf[i++] != '\n');
}
 
template <typename T> inline T readInt()
{
    T n=0,s=1;
    char p=getchar();
    if(p=='-')
        s=-1;
    while((p<'0'||p>'9')&&p!=EOF&&p!='-')
        p=getchar();
    if(p=='-')
        s=-1,p=getchar();
    while(p>='0'&&p<='9') {
        n = (n<< 3) + (n<< 1) + (p - '0');
        p=getchar();
    }
 
    return n*s;
}
#define DEBU
#ifdef DEBUG
    #define debug(args...)     (Debugger()) , args
    class Debugger
    {
        public:
        Debugger(const std::string& _separator = " - ") :
        first(true), separator(_separator){}
 
        template<typename ObjectType> Debugger& operator , (const ObjectType& v)
        {
            if(!first)
                std:cerr << separator;
            std::cerr << v;
            first = false;
            return *this;
        }
        ~Debugger() {  std:cerr << '\n';}
        private:
        bool first;
        std::string separator;
    };
 
#else
    #define debug(args...)
#endif
void time()
{
#ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#endif
}
int factorial(long long n)
{
    return (n==1 || n==0) ? 1: n * factorial(n - 1); 
}
string decimalToBinary(int n) 
{
    string s = bitset<64> (n).to_string(); 
    const auto loc1 = s.find('1'); 
      
    if(loc1 != string::npos) 
        return s.substr(loc1); 
    return "0"; 
}
ll powMod(ll n,ll k,ll m) {
    ll res=1;
    while (k>0) {
        if ((k&1)!=0)
            res=res*n%m;
        n=n*n%m;
        k>>=1;
    }
    return res;
}
void solve() {
    ll n;cin >> n;
    if ((n&(n-1)) == 0){cout << 1 << endl;}
    string x= decimalToBinary(n);
    ll y = pow(2,(x.length()-1));
    cout << n-y+1 << endl;
}
int main(){
    int t = 1;
    while(t--){
        solve();
    }
}