let pr x = print_endline (string_of_int x)

let explode s =
  let rec exp i l =
    if i < 0 then l else exp (i - 1) (s.[i] :: l) in
  exp (String.length s - 1) []

let solve seq =
  let len = List.length seq in
  let (_,_,res) = List.fold_left (fun (cnt,pre,mv) x ->
                      if x != pre then
                        (cnt+1,x,min mv (max cnt (len - cnt)))
                      else (cnt+1,x,mv)) (0,List.hd seq,len) seq in res

let () = input_line stdin
         |> explode 
         |> solve
         |> pr
