Problem:
Score : 500 points

Problem Statement

You are given a string S consisting of 0 and 1.
Find the maximum integer K not greater than |S| such that we can turn all the characters of S into 0 by repeating the following operation some number of times.

Choose a contiguous segment [l,r] in S whose length is at least K (that is, r-l+1\geq K must be satisfied). For each integer i such that l\leq i\leq r, do the following: if S_i is 0, replace it with 1; if S_i is 1, replace it with 0.

Constraints

1\leq |S|\leq 10^5

S_i(1\leq i\leq N) is either 0 or 1.

Input

Input is given from Standard Input in the following format:

S

Output

Print the maximum integer K such that we can turn all the characters of S into 0 by repeating the operation some number of times.

Sample Input 1

010

Sample Output 1

2

We can turn all the characters of S into 0 by the following operations:

Perform the operation on the segment S[1,3] with length 3. S is now 101.

Perform the operation on the segment S[1,2] with length 2. S is now 011.

Perform the operation on the segment S[2,3] with length 2. S is now 000.

Sample Input 2

100000000

Sample Output 2

8

Sample Input 3

00001111

Sample Output 3

4

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <stdio.h>
#include <string.h>

#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define STRS(i,str) for(int i=0;(str)[i];i++)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX3(a,b,c) ((a)>(b)?(a)>(c)?(a):(c):(b)>(c)?(b):(c))
#define MIN3(a,b,c) ((a)<(b)?(a)<(c)?(a):(c):(b)<(c)?(b):(c))
#define MED(a,b,c) ((a)<(b)?(a)>(c)?(a):(b)<(c)?(b):(c):(a)>(c)?(b)<(c)?(c):(b):(a))
#define RNG(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define RNG3(a,b,c) ((a)>(b)?(b)>(c)?(a)-(c):(c)>(a)?(c)-(b):(a)-(b):(b)>(c)?(c)>(a)?(b)-(a):(b)-(c):(c)-(a))
#define MAXS(a,b) {if((a)<(b))(a)=(b);}
#define MINS(a,b) {if((a)>(b))(a)=(b);}
#define BEGINFOR(a,b,c,d,e,f,g,h,i) a;goto i##_6;i##_2:c;goto i##_6;i##_3:h;goto i##_7;i##_4:d;goto i##_8;i##_5:f;goto i##_8;i##_6:if(b)goto i##_4;else goto i##_9;i##_7:if(g)goto i##_5;else goto i##_1;i##_8:if(e)goto i##_2;else goto i##_3;i##_9:
#define CONTINUE(i) goto i##_3
#define BREAK(i) goto i##_1
#define ENDFOR(i) goto i##_3;i##_1:

/*
00000000:8:0000000
00000001:7:0000001
00000010:6:0000011
00000011:6:0000010
00000100:5:0000110
00000101:5:0000111
00000110:5:0000101
00000111:5:0000100
00001000:4:0001100
00001001:4:0001101
00001010:4:0001111
00001011:4:0001110
00001100:4:0001010
00001101:4:0001011
00001110:4:0001001
00001111:4:0001000
00010000:4:0011000
00010001:4:0011001
00011110   0010001
11100000   0010000
11111111   0000000
00000000   0000000
00010010:4:0011011
11100010   0010011
11111100   0000010
00010011: :0011010
00001101
00010100:
00010101:
00010110:
00010111:
00011000:
00011001:
00011010:
00011011: :0010110
00011100:
00011101:
00011110:
00011111:
01111110:7

8
34or34->4
23or45->5
12or56->6
01or67->7

9
34or45->5
000011111
000001111
*/

int main(){
	char ch[120000];
	fgets(ch, 110000, stdin);
	int len = strlen(ch);
	for(int i = (len + 1)/2; i < len; i++){
		if(ch[i] != ch[i - 1] || ch[len - i] != ch[len - i - 1]){
			printf("%d\n", i);
			return 0;
		}
	}
}