s=input()
count=0
while True:
    flag=0
    f=s[0]
    for i in range(len(s)):
        if f == '-':
            f=s[i]
        elif f != s[i]:
            count += 2
            s=s[:i-1]+"--"+s[i+1:]
            flag=1
            f='-'
    s=s.replace("-","")
    if len(s)==0 or flag ==0:
        break
print(count)
