P12189
#include <bits/stdc++.h>
#define int long long
using namespace std;
void putstr(string s){
for(char ch:s){
putchar_unlocked(ch);
}
}
int get(){
int x=0,f=1;
char c=getchar_unlocked();
for (;!isdigit(c);c=getchar_unlocked())if(c=='-')f=-1;
for (;isdigit(c);c=getchar_unlocked()) x=(x<<3)+(x<<1)+(c^48);
return x*f;
}
bool cmp(string a,string b){
return a+b>b+a;
}
string mul2(string a){
int b=0;
for(int c=a.size()-1;c>=0;c--){
int d=(a[c]-'0')*2+b;
a[c]=char(d%10+'0');
b=d/10;
}
if(b) a.insert(a.begin(),char(b+'0'));
return a;
}
string add1(string a){
int b=1;
for(int c=a.size()-1;c>=0 && b;c--){
int d=(a[c]-'0')+b;
a[c]=char(d%10+'0');
b=d/10;
}
if(b) a.insert(a.begin(),char(b+'0'));
return a;
}
void conv(string s){
string b="0";
for(char c:s){
b=mul2(b);
if(c=='1') b=add1(b);
}
putstr(b);
}
string bin(int a,int &b){
string s="";
b=0;
while(a>0ll){
if(a&1ll){
s='1'+s;
b++;
}
else{
s='0'+s;
}
a>>=1ll;
}
return s;
}
signed main(){
int a=get(),b,c=0,d,e,f,g,h,i,j;
vector<string> bins;
string s;
for(i=1;i<=a;++i){
//cout<<bin(i,b)<<endl;
s=bin(i,b);
if(b==s.size()){
c+=b;
}
else{
bins.emplace_back(s);
}
}
sort(bins.begin(),bins.end(),cmp);
s="";
for(i=0;i<c;++i){
s+='1';
}
for(string x:bins){
s+=x;
}
//cout<<s<<endl;
conv(s);
return 0;
}