1267_B. Balls of Buma_5167
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
#include <bits/stdc++.h>
using namespace std;
string inp;
vector<char> diff;
vector<int> cnt;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> inp;
  diff.push_back(inp[0]);
  cnt.push_back(1);
  for (int i = 1; i < inp.size(); i++) {
    if (inp[i] != inp[i - 1]) {
      diff.push_back(inp[i]);
      cnt.push_back(1);
    } else
      (*cnt.rbegin())++;
  }
  if (diff.size() % 2 == 0) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < diff.size() / 2; i++) {
    if (diff[i] != diff[diff.size() - 1 - i]) {
      cout << 0 << endl;
      return 0;
    }
    if (cnt[i] + cnt[diff.size() - 1 - i] < 3) {
      cout << 0 << endl;
      return 0;
    }
  }
  if (cnt[diff.size() / 2] >= 2)
    cout << cnt[diff.size() / 2] + 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}
