#define _USE_MATH_DEFINES #include //string stream its useful! #include #include #include //pair #include // vector #include // swap,sort,binary_search #include // std::greater #include //map #include //set #include //queue #include //list #include #include #include #include //cout< v,int prevk){ /* long sum = 0; for(int i = 0; i<10;i++){ if(p[i]>=2){ p[i]-=2; int k = p[i]; for(int j:v){ if(j != i){ if(j==0||p[j]==0) continue; p[j]--; sum = max(sum,getans(v,p) + j*100 + i*11); p[j]++; }else{ k--; if(k<0) break; } } p[i]+=2; } } return sum; */ long ans = 0; for(int i = prevk +1; i<10;i++){ if (v[i] == 0) continue; for(int j = i+1; j<10;j++){ if (v[i] == v[j]) continue; for(int k = j+1; k<10;k++){ if(v[j] == v[k]) ans = max(ans,getans(v,k) + i*100 + j*10 + k * 1); } } } return ans; } int main(){ omajinai(); ll N; cin>>N; vector v; while(true){ v.push_back(N%10); if(N<10) break; N/=10; } reverse(v.begin(),v.end()); cout<