import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    val stack = LinkedList<Char>()
    s.forEach {
        if (stack.isNotEmpty()) {
            val last = stack.last()
            if (it != last) {
                stack.removeLast()
            } else {
                stack.add(it)
            }
        } else {
            stack.add(it)
        }
    }
    println(s.length - stack.size)
}