#include<iostream> using namespace std; int main(){ unsigned int n, x; while(cin>>n &&n){ x = n&-n; cout<<(n+x+(n^(n+x))/x/4)<<" "; } return 0; }