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