'use strict'

function Main(input) {
  let ret = remove(input)
  let ans = ret[1]
  while(true) {
    const before = ans
    ret = remove(ret[0])
    ans += ret[1]
    if (before === ans) {
      console.log(ans)
      return
    }
  }
}

function remove(s) {
  const len = s.length
  const S1 = s.split("10").join("") 
  let ans = 0
  ans += len - S1.length
  const S2 = S1.split("01").join("")
  ans += S1.length - S2.length

  return [S2, ans]
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim())
