S = input()
def solve_schedule():
    check = S
    res = 0
    while True:
        loop_res = 0
        next = ''
        while len(check) > 0:
            if len(check) == 1:
                next += check
            if check[-2:] == '01' or check[-2:] == '10':
                loop_res += 2
                check = check[:-2]
            else:
                next += check[-1:]
                check = check[:-1]
        next = next[::-1]

        res += loop_res
        if loop_res == 0: break
        check = next

    print(res)

solve_schedule()