s = input()
n = len(s)


def divide(x):
    a = "".join(x.split("01"))
    b = "".join(a.split("10"))
    return b


def judge(x):
    return len(x.split("01")) == 1 and len(x.split("10")) == 1


while not judge(s):
    s = divide(s)

print(n - len(s))
