
S = input()
s = S

before_len = 0
while True:
    s = s.replace('0011', '').replace('1100', '').replace('0101', '').replace('1010', '').replace('01', '').replace('10', '')
    lens = len(s)
    if before_len == lens:
        break

    before_len = lens


print(len(S) - len(s))