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

let lst = Str.split (Str.regexp "") (read_line ())
          |> List.map int_of_string 

let my_not n =
        if n = 0 then
                1
        else
                0

let head =
        let len = List.length lst in
        let head = List.hd lst in
        let last = List.last lst in
                if (len mod 2 = 0 && head = last) || (len mod 2 = 1 && head != last) then
                        my_not head
                else
                        head

let rec f lst ac =
        match lst with
                  [] -> 0
                | first :: rest -> 
                        if first = ac then
                                1 + (f rest (my_not first))
                        else
                                (f rest first)
let () = 
        f (List.tl lst) head
        |> Printf.printf "%d\n"
(*
let hlst, tlst = 
        let len = (List.length lst) in
        let hlen = len / 2 in
        let tlen = len - hlen in
                List.filteri (fun i elmnt -> i < hlen) lst,
                List.filteri (fun i elmnt -> i < tlen) (List.rev lst)

let my_not n =
        if n = 0 then
                1
        else
                0

let i = ref 0
let init lst =
        let len = List.length lst in
        let head = List.hd lst in
        let last = List.last lst in
                if (len mod 2 = 0 && head = last) || (len mod 2 = 1 && head != last) then
                        (
                                incr i;
                                (my_not head), last
                        )
                else
                        head, last


let rec f head lst =
        match lst with
                [] -> 0
                | first :: rest -> 
                        if head = first then
                                1 + (f (my_not first) rest)
                        else
                                f first rest

let ans =
        let head, tail = init lst in
                (f head hlst) + (f tail tlst)
*)
