t = input() n = len(t) aa = [int(c) for c in t] def dfs(i, s): if i == n - 2: return 0 if s >> i & 1: return dfs(i + 1, s) res = dfs(i + 1, s) for j in range(i + 1, n - 1): if s >> j & 1: continue if aa[i]==aa[j]:continue for k in range(j + 1, n): if s >> k & 1: continue if aa[j] == aa[k]: ns = s | 1 << j | 1 << k cur = 100 * aa[i] + 11 * aa[j] + dfs(i + 1, ns) res = max(res, cur) return res print(dfs(0, 0))