import math
s = list(input())
s = list(map(int, s))
s_ori = s.copy()
s_len = len(s)

s_new=[]
for _ in range(200000):
    count=0
    s_len = len(s)
    if s_len ==1:
        #print('a')
        break
    for i in range(1,s_len):
        if count %2==1:
            count +=1
            if i +1==s_len:
                s_new.append(s[-1])
            continue
        if s[i] is not s[i-1]:
            count +=1
        else:
            s_new.append(s[i-1])
            if i +1==s_len:
                s_new.append(s[-1])
    #print(s_new)
    if s==s_new:
        s = s_new
        break
    s = s_new
    s_new=[]
    
#print(s_ori)    
#print(s)
print(math.floor((len(s_ori)-len(s))/2)*2)
            