import sys
sys.setrecursionlimit(10**5-10**4*2)
S = list(input())
n = len(S)

def f(flist,count):
    if len(count) == 0:
        return flist
    else:
        del flist[count[0]]
        del count[0]
        count = list(map(lambda x: x-1,count))
        return f(flist,count)

def Remove(binList,lenList):
    if list(set(binList)) == ["0"] or list(set(binList)) == ["1"]:
        return binList
    count = []
    count.clear()
    for i in range(0,lenList-1):
        if (binList[i] == "0" and binList[i+1] == "1") or (binList[i] == "1" and binList[i+1] == "0"):
            count += [i,i+1]

    count = list(set(count))
    binList = f(binList,count)
    lenList = len(binList)

    if len(count) == 0:
        return binList
    else:
        return Remove(binList, lenList)

S = Remove(S,n)
print(n-len(S))