(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let lst = Str.split (Str.regexp "") (read_line ())

let i = ref 0
let rec f lst =
        match lst with
                  [] -> []
                | "0" :: "0" :: "0" :: rest -> 
                        incr i;
                        "0" :: "1" :: (f ("0" :: rest))
                | "1" :: "1" :: "1" :: rest -> 
                        incr i;
                        "1" :: "0" :: (f ("1" :: rest))
                | first :: rest -> 
                        first :: (f rest)

let rec f2 lst = 
        match lst with
                  [] -> []
                | "0" :: "0" :: rest -> 
                        incr i;
                        "0" :: (f2 ("1" :: rest))
                | "1" :: "1" :: rest -> 
                        incr i;
                        "1" :: (f2 ("0" :: rest))
                | first :: rest -> 
                        first :: (f2 rest)

let anslst = f2 (f lst)
let () = Printf.printf "%d\n" !i
