#include #include #include #include using namespace std; using namespace atcoder; using namespace __gnu_pbds; using ll=long long; using ld=long double; using vll=vector; using vvll=vector; using pll=pair; // using mint=modint; // template // using ordered_map=tree,rb_tree_tag,tree_order_statistics_node_update>; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll N,x=0,y=0; cin>>N; while(N>0){ y=max(y,x+2*N); x+=N; N/=2; } cout<