#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
string makeLargestSpecial(string S) {
if(S == "") return "";
vector<string> v;
int cnt = 0;
for(int start = 0, i = 0; i < S.size(); i ++){
cnt += (S[i] == '1' ? 1 : -1);
if(!cnt){
v.push_back("1" + makeLargestSpecial(S.substr(start + 1, i - start - 1)) + "0");
start = i + 1;
}
}
sort(v.begin(), v.end(), greater<string>());
string res = "";
for(const string& e: v) res += e;
return res;
}
};
int main() {
cout << Solution().makeLargestSpecial("11011000") << endl;
return 0;
}