package main
import (
  "fmt"
  "strings"
)
func main() {
  var s,t,u string
  var m1,m2 int
  fmt.Scan(&s)
  t = s
  for {
    u = strings.Replace(t,"01","",-1)
    if t == u { break }
    t = u
  }
  m1 = len(s)-len(t)
  t = s
  for {
    u = strings.Replace(t,"10","",-1)
    if t == u { break }
    t = u
  }
  m2 = len(s)-len(t)
  fmt.Println(max(m1,m2))
}
func max(n int,m int) int {
  if n > m {
    return n
  } else {
    return m
  }
}