#C
S = input()
N = len(S)
SL = list(map(int, list(S)))

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