#include<bits/stdc++.h> using namespace std; int x; int dfs(int x){ if(x<=1)return x; int k=dfs(x/2); if(x&1)k+=k+1; else k+=k; int tmp=dfs(k/2); if(x&1)return tmp+tmp+1; else return tmp+tmp; } int main(){ cin>>x; cout<<dfs(x)<<endl; return 0; }