import itertools N = [int(x) for x in list(input())] def rec(n): if len(n) < 2: return 0 res = 0 for selector in itertools.combinations(range(len(n)), 3): num = [x for i, x in enumerate(n) if i in selector] cww = 0 if num[0] and num[0] != num[1] == num[2]: cww = num[0] * 100 + num[1] * 10 + num[2] remains = [x for i, x in enumerate(n) if i not in selector] res = max(res, cww + rec(remains)) return res print(rec(N))