let () =
  Scanf.scanf "%s" @@ fun s ->
  let len = String.length s in
  let rec f a stk i =
    if i = len then 2*a
    else
      match stk, s.[i] with
      | [], c         -> f a [c] (i+1)
      | '0'::stk, '1' -> f (a+1) stk (i+1)
      | '1'::stk, '0' -> f (a+1) stk (i+1)
      | _, c  -> f a (c::stk) (i+1)
  in f 0 [] 0 |> Printf.printf "%d\n"