human
Balph is learning to play a game called Buma. In this game, he is given a row of colored balls. He has to choose the color of one new ball and the place to insert it (between two balls, or to the left of all the balls, or to the right of all the balls).

When the ball is inserted the following happens repeatedly: if some segment of balls of the same color became longer as a result of a previous action and its length became at least 3, then all the balls of this segment are eliminated. 

Consider, for example, a row of balls 'AAABBBWWBB'. Suppose Balph chooses a ball of color 'W' and the place to insert it after the sixth ball, i. e. to the left of the two 'W's. After Balph inserts this ball, the balls of color 'W' are eliminated, since this segment was made longer and has length 3 now, so the row becomes 'AAABBBBB'. The balls of color 'B' are eliminated now, because the segment of balls of color 'B' became longer and has length 5 now. Thus, the row becomes 'AAA'. However, none of the balls are eliminated now, because there is no elongated segment.

Help Balph count the number of possible ways to choose a color of a new ball and a place to insert it that leads to the elimination of all the balls.

Input

The only line contains a non-empty string of uppercase English letters of length at most 3 ⋅ 10^5. Each letter represents a ball with the corresponding color.

Output

Output the number of ways to choose a color and a position of a new ball in order to eliminate all the balls.

Examples

Input

BBWWBB

Output

3

Input

BWWB

Output

0

Input

BBWBB

Output

0

Input

OOOWWW

Output

0

Input

WWWOOOOOOWWW

Output

7
 ... Write me a the Python program you requested?
assistant
#Here is the Python program you requested.

def main():
    
    s=input()
    
    # first check if it's possible...
    n=len(s)
    l=0
    r=n-1
    ok=True
    while True:
        if s[l]!=s[r]:
            ok=False
            break
        c=s[l]
        lCnt=0
        rCnt=0
        while s[l]==c and l<r:
            l+=1
            lCnt+=1
        while s[r]==c and r>l:
            r-=1
            rCnt+=1
        if l==r: # possible
            break
        if lCnt+rCnt<3:
            ok=False
            break

    if ok:
        c=s[l]
        while l-1>=0 and s[l-1]==c:
            l-=1
        while r+1<n and s[r+1]==c:
            r+=1
        if l==r: # only 1 ball... cannot
            print(0)
        else:
            print(r-l+2)
    else:
        print(0)
    return
    
import sys
# input=sys.stdin.buffer.readline #FOR READING PURE INTEGER INPUTS (space separation ok)
input=lambda: sys.stdin.readline().rstrip("\r\n") #FOR READING STRING/TEXT INPUTS.
 
def oneLineArrayPrint(arr):
    print(' '.join([str(x) for x in arr]))
def multiLineArrayPrint(arr):
    print('\n'.join([str(x) for x in arr]))
def multiLineArrayOfArraysPrint(arr):
    print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))
 
def readIntArr():
    return [int(x) for x in input().split()]
# def readFloatArr():
#     return [float(x) for x in input().split()]

def makeArr(defaultVal,dimensionArr): # eg. makeArr(0,[n,m])
    dv=defaultVal;da=dimensionArr
    if len(da)==1:return [dv for _ in range(da[0])]
    else:return [makeArr(dv,da[1:]) for _ in range(da[0])]
 
def queryInteractive(x,y):
    print('? {} {}'.format(x,y))
    sys.stdout.flush()
    return int(input())
 
def answerInteractive(ans):
    print('! {}'.format(ans))
    sys.stdout.flush()
 
inf=float('inf')
MOD=10**9+7
 
 
for _abc in range(1):
    main()