#!/usr/bin/python
# coding: UTF-8

S = list(input())
S = list(map(int,S))
S.append(-1)
S.insert(0,-2)
Count = 0
Before = len(S)
while True:
    L = len(S) - 2
    for i in range(L,1,-1):
        if S[i] !=  S[i+1] and S[i] != -2 and S[i+1] != -1:
            #print(S)
            S.pop(i)
            S.pop(i)
            i += 1
            if i > L:
                break
    else:
        break

#print(S)
print(Before - len(S))