l={} def f(s,n): l[n]=1 for i in s: p,q=s.split(i,1) for j in s:'0'1!=f(p+q.replace(j,'',2),n+int(i+j+j)) f(input(),0) print(max(l))