g={}
def f(s,n):
 g[n]=1
 for i in s:
  a,b=s.split(i,1);['0'<i!=j!=b.count(j)>1!=f(a+b.replace(j,'',2),n+int(i+j+j))for j in b]
f(input(),0)
print(max(g))