import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}

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

  auto n = s.length.to!int, k = (n+1)/2+1;
  for (; k <= n; ++k)
    if (s[k-1] != s[n-k] || s[k-1] != s[k-2]) break;

  writeln(k-1);
}
