#include <iostream> #include <string> using namespace std; bool search(string s, char a) { for (int i = 0; i < s.size(); i++) if (s[i] == a) return true; return false; } int main() { string s; while (cin>>s) { for (char i = '9'; i >= '0'; i--) { int j = 0; bool b = false; while (1) { if (s[j] == i) { if (b) { s.erase(j,1); j--; } else { if (s[j] < s[j + 1] && search(s.substr(j+1),i)) { s.erase(j,1); j--; } else b = true; } } j++; if (j >= (s.length() - 1)) { if (b&&s[j]==i) s.erase(j,1); break; } } } cout << s << endl; } }