import scala.io.StdIn._

object Main extends App {
  val s = readLine()

  var count1 = 1
  while (count1 < s.length && s(count1) == s.head) {
    count1 += 1
  }

  var index = s.length - 2
  var count2 = 1
  while (0 <= index && s(index) == s.last) {
    count2 += 1
    index -= 1
  }

  val countMax = math.max(count1, count2)
  val restMax = math.max(s.length - count1, s.length - count2)

  println(math.max(countMax, restMax))
}
