# include # define int long long # define FILE(x) freopen(x ".in", "r", stdin); freopen(x ".out", "w", stdout); using namespace std; int n; string s; int a[20]; int f[5005]; int ans; void solve() { cin >> s; n = s.size(); for (int i = 0; i < n; i ++) { a[i] = s[i] - '0'; } fill(f + 1, f + 1 + n, -1e18); for (int s = 0; s < (1 << n); s ++) { if (f[s] == -1e18) continue; for (int i = 0; i < n; i ++) { if (!a[i]) continue; for (int j = i + 1; j < n; j ++) { for (int k = j + 1; k < n; k ++) { if (a[j] != a[k]) continue; if (a[i] == a[j]) continue; if ((s & ((1 << i) | (1 << j) | (1 << k))) == 0) { int ns = s | (1 << i) | (1 << j) | (1 << k); f[ns] = max(f[ns], f[s] + a[i] * 100 + a[j] * 11); } } } } } cout << *max_element(f, f + (1 << n)); } signed main() { ios :: sync_with_stdio(0); cin.tie(0), cout.tie(0); int T = 1; while (T --) solve(); return 0; }