#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; for(int mask = 1;mask < (1 << N) - 1;mask++){ ll res = 0; map cnt; deque used(N,false); for(int i = N - 1;i >= 0;i--) if((mask & (1 << i)) == 0 && used [i] == false){ used [i] = true; if(++cnt [S [i]] == 2){ cnt [S [i]] = 0; for(int j = i - 1;j >= 0;j--) if(mask & (1 << j)){ if(used [j] == false && S [j] != '0' && S [j] != S [i]){ used [j] = true; res += (S [j] - '0') * 100 + (S [i] - '0') * 11; break; } } } } chmax(ans,res); } cout << ans << endl; return 0; }