import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import itertools N = [x - ord('0') for x in read().rstrip()] def F(N): items = len(N) best = 0 for i,j,k in itertools.combinations(range(items), 3): if not (N[i] != N[j] == N[k]): continue A = [x for ind, x in enumerate(N) if ind not in [i,j,k]] x = F(A) + N[i] * 100 + N[j] * 11 if best < x: best = x return best print(F(N))