inData = str(input())
ansList = []
dataLen = len(inData)
rpLen = len(inData)
for i in range(0, dataLen):
    for j in range(1, rpLen + 1):
        if inData[-j] != inData[-j - 1]:
            ansList.append(inData[-j])
            ansList.append(inData[-j - 1])
            tmp1 = str(inData[0:-j - 1])
            tmp2 = ''
            if -j + 1 != 0:
                tmp2 = str(inData[-j + 1:])
            reData = tmp1 + tmp2
            if reData == '[]':
                inData = '[]'
            else:
                inData = reData
            break
        else:
            if rpLen == j + 1:
                break
    if inData == '[]':
        break
    rpLen = len(inData)
    if rpLen < 2:
        break

print(len(ansList))
