#include using namespace std; #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) using ll = long long; using P = std::tuple; const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1}; string S; int dp[1 << 15]; int rec(int status){ if(dp[status] != -1){return dp[status];} int l = S.size(), res = 0; for(int i=0;i> i & 1) || (status >> j & 1) || (status >> k & 1) || S[i] == '0' || S[j] != S[k] || S[i] == S[j]){ continue; } res = max(res, 100 * (S[i]-'0') + 11 * (S[j]-'0') + rec(status | (1 << i) | (1 << j) | (1 << k))); } } } return dp[status] = res; } int main(){ //* std::cin.tie(nullptr); std::ios::sync_with_stdio(false); /*/ /*/ std::cin >> S; memset(dp, -1, sizeof(dp)); std::cout << rec(0) << std::endl; }