# s1 = input()
# len_s = len(s1)
# s2 = s1
# while True:
#     len_1 = len(s2)
#     s2 = s2.replace("01", "").replace("10", "")
#     len_2 = len(s2)
#     if len_1 == len_2:
#         break
#
# print(len_s - len(s2))

s = input()
s2 = s
for i in range(len(s), 0, -1):
    # print("i", i)
    # print("s2", s2)
    m1 = "1" * i + "0" * i
    m2 = "0" * i + "1" * i
    s2 = s2.replace(m1, "").replace(m2, "")

while True:
    len_1 = len(s2)
    s2 = s2.replace("01", "").replace("10", "")
    len_2 = len(s2)
    if len_1 == len_2:
        break
print(len(s) - len(s2))
