def main(ans):
    S = input()
    S_list = [int(S[i]) for i in range(len(S))]
    rm_list = []
    for aaa in range(len(S) // 2):
        for i in range(len(S_list) - 1):
            if S_list[i] != S_list[i + 1] and i not in rm_list:
                rm_list.append(i)
                rm_list.append(i + 1)
        S_list = [S_list[i] for i in range(len(S_list)) if i not in rm_list]
        if len(rm_list) == 0:
            return
        ans += len(rm_list)
        rm_list = []


ans = 0
main(ans)
print(ans)
