s=input();l=len(s);m=0 for i in range(l): for j in range(i+1,l): for k in range(j+1,l): if s[j]==s[k]and s[i]!=s[j]:m=max(m,int(s[i]+s[j]*2)) print(m)