object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val s = sc.next()
  val n = s.length
  if (n % 2 == 0) {
    val s1 = s.take(n/2).reverse
    val s2 = s.drop(n/2)
    if (s1.head == s2.head) {
      val idx1 = s1.indexWhere(_ != s1.head)
      val t1 = if (idx1 == -1) n/2 else idx1
      val idx2 = s2.indexWhere(_ != s2.head)
      val t2 = if (idx2 == -1) n/2 else idx2
      println(n/2 + t1.min(t2))
    } else {
      println(n/2)
    }
  } else {
    val s1 = s.take(n/2).reverse
    val s2 = s.drop(n/2)
    val t = s(n/2)
    val idx1 = s1.indexWhere(_ != t)
    val t1 = if (idx1 == -1) n/2 else idx1
    val idx2 = s2.indexWhere(_ != t)
    val t2 = if (idx2 == -1) n/2 else idx2
    println(n/2 + t1.min(t2) + 1)
  }
}
