import numpy as np

DEBUG = 0

def to_s(lis):
    return "".join(map(str, lis))

def erase(lis, cnt):
    if DEBUG==1:   
        print("try")
    
    i = 0
    this_cnt = 0
    while(i < len(lis)-1):
        #if DEBUG==1:
            #print ("in while loop")
            
        if lis[i] != lis[i+1]:
            del lis[i]
            del lis[i]
            this_cnt += 1
            cnt += 1
            if DEBUG==1:
                print(cnt, to_s(lis))
        else:
            i+=1
            
    if DEBUG==1:
        print("cnt so far: ", cnt, "this_cnt: ", this_cnt)

    if this_cnt > 0:
        erase(lis, cnt)

    return lis

        
def main():
    string = input()
    lis = [int(v) for v in string]

    if DEBUG==1:
        print("start: ")
        print(to_s(lis))

    
    erase(lis, 0)
    #print(cnt, to_s(lis))
    ans = len(string)-len(lis)
    print(ans)
main()
