
def C():
    S = input()
    lS = []
    lS_val = []
    for a in S:
       lS.append(int(a)) 
    
    vx_1 = lS[0]
    if len(lS) <= 1:
        print('0')

    else:
        for i, value in enumerate(lS):
            if i==0:
                vx_1 = value
                continue

            if vx_1 != value:
                a = copy.deepcopy(lS)
                a.pop(i)
                a.pop(i-1)
                if len(a) != 0:
                    lS_val.append(roop(a, 2) + 2)

                else:
                    lS_val.append(2)

            vx_1 = value 
        
        print(max(lS_val))

    

def roop(lS, score): 
    vx_1 = lS[0]

    for i, value in enumerate(lS[1:]):
        if vx_1 != value:
            a = copy.deepcopy(lS)
            a.pop(i)
            a.pop(i-1)
            if len(a) != 0:
                score = roop(a, 2) + 2
            else:
                score = score + 2
        vx_1 = value 
    return score


def D():
    pass

if __name__ =='__main__':
    C()