s = str(input())
s_bef = s
s_len = len(s)
for x in reversed(range(1, s_len)):
    s = s.replace("0" * x + "1" * x, "").replace("1" * x + "0" * x, "")

while len(s_bef) > len(s):
    s_bef, s = s, s.replace("01", "").replace("10", "")
 
print (s_len - len(s))