package main
 
import (
  "bufio"
  "fmt"
  "os"
  "strings"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func main() {
  if sc.Scan() {
    s := sc.Text()
    str := f(s)
    fmt.Printf("%d", len(s) - len(str))
  }
}

func f(s string)(str string) {
  ss := strings.Replace(s, "01", "", -1)
  str = strings.Replace(ss, "10", "", -1)
  if s != str {
    str = f(str)
  }
  return
}