# encoding:utf-8
import copy
import numpy as np
import random
import pandas as pd
import torch


s = list(str(input()))

escape = False
begin = len(s)

def rem(s):
    for i in range(1,len(s)):
        # print(s)
        if s[i-1] != s[i]:
            s.pop(i)
            s.pop(i-1)
            break
    return s


for i in range(10**4):
    s = rem(s)

end = len(s)
print(begin-end)
