S = str(input())

def del_cube(s, i):
    s = s[:i] + s[i+2:]
    return s

def dfs(s):
    ans_list = []
    flag = True
    if '10' in s:
        flag = False
        s_10 = s.replace('10', '')
        ans_list.append(dfs(s_10))
    if '01' in s:
        flag = False
        s_01 = s.replace('01', '')
        ans_list.append(dfs(s_01))
    
            
    if flag == True:
        return(len(s))
    else:
        return(min(ans_list))
    
print(len(S) - dfs(S))

