#include using namespace std; using ll=long long; #define rep2(i, a, n) for(int i = (a); i < (n); i++) #define rep(i, n) rep2(i,0,n) int main(){ cin.tie(nullptr);ios_base::sync_with_stdio(false); string x;cin>>x; vector vec; rep(i,x.size()){ vec.push_back(x[i]); } sort(vec.begin(),vec.end()); string shake; vector hoge; do { shake=""; rep(i,x.size()){ shake+=vec[i]; } if(shake[0]!='0')hoge.push_back(stoi(shake)); }while(next_permutation(vec.begin(),vec.end())); if(hoge.size()!=1){ sort(hoge.rbegin(),hoge.rend()); cout<