import io.{StdIn => in}

object Main extends App {
  val s = in.readLine.map(c => if(c == 'W') true else false).toBuffer
  def rec(norm:Boolean,  cnt:Int, size:Int):Unit = {
    if(cnt == size || s(cnt) == norm) return
    else {
      s(cnt) = norm
      rec(norm, cnt+1, size)
    }
  }

  def f(norm:Boolean, cnt:Int):Int = {
    if(s.forall(_ == norm) || s.forall(_ == !norm)) cnt
    else {
      rec(norm, 0, s.size)
      norm +=: s
      f(!norm, cnt + 1)
    }
  }

  val ans = f(!s.head, 0)
  println(ans)
}
