s = input()
l = len(s)

while True:
    if s.count('0') == 0 or s.count('1') == 0:
        break
    elif 4 <= len(s):
        s = s.replace('0011', '')
        s = s.replace('1010', '')
        s = s.replace('0101', '')
        s = s.replace('1100', '')
    else:
        s = s.replace('01', '')
        s = s.replace('10', '')

print(l - len(s))