S = input()
S = S + S[-1]
res = 0
tmp1 = 0
tmp0 = 0
now = 0
while True:
    if S[now] != S[now + 1]:
        res += 2
        flag = True
        now += 1
    else:
        if S[now] == '1':
            tmp1 += 1
        else:
            tmp0 += 1
            
        flag = False
        
    now += 1
    if now >= len(S) - 1:
        break
        
    
    
if flag == False:
    if S[len(S) - 1] == '1':
        tmp1 += 1
    else:
        tmp0 += 1
        
print(res + 2 * min(tmp1, tmp0))
    