import sequtils, strutils, math, algorithm

var
  s = readLine(stdin)
  s_orig = s
  count = 0
while true:
  var s_temp = s
  s = s.replace("01")
  s = s.replace("10")
  if s_temp == s:
    break
echo (s_orig.len - s.len)