import java.util.*

fun main(args:Array<String>) {
    val cubes = readLine()!!
    val stk = Stack<Char>()
    stk.push(cubes[0])
    for(i in (1 until cubes.length)) {
        if(stk.isNotEmpty() && stk.peek() != cubes[i]) {
            stk.pop()
        } else {
            stk.add(cubes[i])
        }
    }
    print(cubes.length - stk.size)
}
