#include using namespace std; #define FOR(i,l,r) for(int i = (l);i < (r);i++) #define ALL(x) (x).begin(),(x).end() template bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;} template bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;} typedef long long ll; int N; string S; int main() { cin >> S; N = S.size(); ll ans = 0; map cnt; deque used(N,false); for(int i = N - 1;i >= 0;i--){ if(used [i] == false && ++cnt [S [i]] == 2){ cnt [S [i]] = 0; int mx = -1; FOR(j,0,i){ if(used [j] == false && S [j] != '0' && S [j] != S [i] && (mx == -1 || S [j] > S [mx])){ mx = j; } } if(mx == -1) continue; used [mx] = true; ans += (S [mx] - '0') * 100 + (S [i] - '0') * 11; } } cout << ans << endl; return 0; }