package main

import (
	"fmt"
	"strings"
)

var r = strings.NewReplacer("01", "", "10", "")

func remove(s string) string {
	if !strings.Contains(s, "01") && !strings.Contains(s, "10") {
		return s
	}
	replaced := r.Replace(s)
	return remove(replaced)
}

func main() {
	var s string

	fmt.Scan(&s)

	replaced := remove(s)
	fmt.Println(len(s) - len(replaced))
}
