import numpy as np
import copy

cubes = list(input())
cubes = list(map(int, cubes))

def removeCubes(cubeList, cnt):
    cubeArray = np.array(cubeList)
    originalList = copy.deepcopy(cubeList)
    max = 0
    resultList = []
    for i in range(0, len(cubeArray) - 1):
        if cubeArray[i] != cubeArray[i + 1]:
            cubeList.pop(i)
            cubeList.pop(i)
            resultList.append(removeCubes(cubeList, cnt + 1))
            cubeList = copy.deepcopy(originalList)
    if len(resultList) == 0:
        return cnt
    elif len(resultList) == 1:
        return resultList[0]
    else :
        maxRet = 0
        for j in range(0, len(resultList)):
            if maxRet < resultList[j]:
                maxRet = resultList[j]
        return maxRet

print(removeCubes(cubes, 0) * 2)