let pr x = print_endline @@ string_of_int x

let fold f init s =
  let rec iter i res =
    if i < 0 then res else iter (i - 1) (f res s.[i]) in
  iter (String.length s - 1) init

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

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