
s=input()
flag=1
length=len(s)
s_flag=[1 for _ in range(length)]
while flag:
    l=sum(s_flag)
    if l<=1:
        break
    comp=0
    while s_flag[comp]==0:
        comp+=1
    # print(s_flag,comp)
    for i in range(comp+1,length):
        if s_flag[i]:
            if s[comp]!=s[i]:
                s_flag[comp]=0
                s_flag[i]=0
                break
            else:
                comp=i
                if i==length-1:
                    flag=0
print(length-sum(s_flag))
