let one_color s =
  not (String.contains s 'W' && String.contains s 'B')

let flip s =
  let len = String.length s in
  let newcolor = if s.[(len-1)] = 'W' then 'B' else 'W' in
  let rec aux i =
    if i = -1 then String.make len newcolor
    else if s.[i] <> newcolor then aux (i-1)
    else (String.sub s 0 (i+1)) ^ (String.make (len - i) newcolor)
  in 
  aux (len - 1)

let rec solve s count =
  if one_color s then count
  else solve (flip s) (count + 1)

let () =
  let s = Scanf.scanf "%s" (fun s -> s) in
  Printf.printf "%d\n" (solve s 0)