import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.regex;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  string s; readV(s);

  auto r = 0;
  auto m0 = s.matchAll(r"0+");
  r = max(r, m0.front.empty ? 0 : m0.front.map!(mi => mi.length).reduce!min.to!int);
  auto m1 = s.matchAll(r"1+");
  r = max(r, m1.front.empty ? 0 : m1.front.map!(mi => mi.length).reduce!min.to!int);

  auto n = s.length.to!int, c = s[n/2];
  foreach (i; (n+1)/2..n+1) {
    if (s[i-1] != c || s[n-i] != c) {
      r = max(r, i-1);
      break;
    }
  }

  writeln(r);
}
