Scanf.scanf "%s" (fun s ->
    let n = String.length s in

    let rec loop k acc =
        if k = n - 1 then acc else
            if s.[k] = s.[k + 1] then loop (k + 1) acc else
                let l = k + 1 in
                loop (k + 1) (min acc (max l (n - l)))
    in
    loop 0 n |> Printf.printf "%d\n"
)