import java.util.*

fun main(args: Array<String>) {

    val sc = Scanner(System.`in`)
    val S = sc.next().toCharArray()
    var list = S.toList()
    var isRun = true
    var ans:Long = 0
    while (isRun) {
        isRun = false
        var pre = 'N'
        var nextList = mutableListOf<Char>()
        for (c in list) {
            if (pre == c) {
                ans += 2
                nextList.removeAt(nextList.size-1)
                isRun = true
            }else {
                nextList.add(c)
            }
            pre = c
        }
        list = nextList
    }
    println(ans)
}