#include using namespace std; #define REP(i,n) for(int i=0;i ostream& operator<<(ostream& os,const vector& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; } template ostream& operator<<(ostream& os,const pair& p){ os << "(" << p.first << ","<< p.second <<")"; return os; } typedef long long ll; typedef unsigned long long ull; typedef pair pii; typedef vector vi; typedef vector vvi; ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); } constexpr ll mod = 1e9+7; const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1}; int main(){ string s;cin>>s; int n=s.size(); vector use(n,0); int ans = 0; for(int i=9;i>0;i--){ // c for(int j=0;jj;k--) for(int l=k-1;l>j;l--){ if(s[j]!=s[k] and s[k]==s[l] and use[k]==0 and use[l]==0){ // s[j]:c , s[k]:w , s[l]:w int c = s[j]-'0'; int w = s[k]-'0'; ans += (c*100+w*10+w); use[j]=1; use[k]=2; use[l]=2; goto PO; } } PO:; } } for(int i=0;i