import copy as copy
s = input()
dic={}

def pre():
    global s
    n = 0
    while '1100' in s:
        s=s.replace('1100', '10', 1)
        n+=2

    while '0011' in s:
        s=s.replace('0011', '01', 1)
        n+=2
    
    while '10101' in s:
        s=s.replace('10101', '101', 1)
        n+=2
    
    while '01010' in s:
        s=s.replace('01010', '010', 1)
        n+=2

    return n

def func(val, n):
    if val in dic:
        return dic[val]

    if not ('1' in val):
        return n
    elif not ('0' in val):
        return n
    a=0
    b=0    
    if '01' in val:
        a = func(val.replace('01', '', 1), n+2)
    if '10' in val:
        b = func(val.replace('10', '', 1), n+2)
    
    ans=max(a, b, n)
    dic[val]=ans

    return ans

ans=pre()
print(func(s, ans))
