function main()
  s = readline()
  so = s[:]
  while lentgh(s) >1 && s != "1"^length(s) && s != "0"^length(s) 
    for i = lenght(s)-1:-2:1
      if i == 1
        if s[1:2] == "00" || s[1:] =="11" 
        elseif length(s) >=3
          s = s[3:]
        else 
          s =""
        end
      else
        if (parse(Int, s[i]) $ parse(Int, s[i-1])) == 0
          s = s[1:i-2] * s[i+1:]
        end
      end
    end
  if length(s) >=2 
    for i = lenght(s):-2:1
      if i == 1
        if s[1:2] == "00" || s[1:] =="11" 
        elseif length(s) >=3
          s = s[3:]
        else 
          s =""
        end
      else
        if (parse(Int, s[i]) $ parse(Int, s[i-1])) == 0
          s = s[1:i-2] * s[i+1:]
        end
      end
    end
    end
  end
  println(Int64(length(so) - length(s)))
end
main()