def crmv(c,istr):
    if len(istr)<=1:
        return c
    
    lidx=[]
    for i in range(len(istr)-1):
        if istr[i] != istr[i+1]:
            lidx.append(i)
    if len(lidx)==0:
        return c

    rv=0
    for i in lidx:
        tstr=istr[:i]+istr[i+1+1:]
        r=crmv(c+1,tstr)
        if r>rv:
            rv=r
    return rv

istr=input()

print(crmv(0,istr)*2)