# -*- coding: utf-8 -*-

S = input()
N = len(S)
L = int(S, 2)   # 2進表記の整数に変換

# O(N^2)は不可。
# 010がある時、01と10を取り除くパターンを作る？

cnt = 0
s = set()
s.add(S)
while True:
    #print(s)
    s2 = set()
    for d in s:
        for i in range(len(d)-1):
            if d[i] != d[i+1]:
                ns = None
                if i+2 < len(d):
                    ns = d[:i]+d[i+2:]
                else:
                    ns = d[:i]
                if ns is not None and len(ns) > 0:
                    s2.add(ns)
    if len(s2) > 0:
        cnt += 2
        s = s2
    else:
        break

print(cnt)
