#C
S = input()
N = len(S)
SL = list(S)

red  = '0'
blue = '1'
cnt = 1
total = 0
while cnt != 0 and len(SL) >= 2:
    cnt = 0
    i = 1
    tmpSL = []
    while i < len(SL):
        if SL[i-1] != SL[i]:
            i += 2
            cnt += 2
            if i >= len(SL):
                tmpSL.append(SL[-1])
        else:
            tmpSL.append(SL[i - 1])
            i += 1
    SL = tmpSL
    total += cnt
print(total)
