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