You are given a set of points on a straight line. Each point has a color assigned to it. For point a, its neighbors are the points which don't have any other points between them and a. Each point has at most two neighbors - one from the left and one from the right.

You perform a sequence of operations on this set of points. In one operation, you delete all points which have a neighbor point of a different color than the point itself. Points are deleted simultaneously, i.e. first you decide which points have to be deleted and then delete them. After that you can perform the next operation etc. If an operation would not delete any points, you can't perform it.

How many operations will you need to perform until the next operation does not have any points to delete?

Input

Input contains a single string of lowercase English letters 'a'-'z'. The letters give the points' colors in the order in which they are arranged on the line: the first letter gives the color of the leftmost point, the second gives the color of the second point from the left etc.

The number of the points is between 1 and 106.

Output

Output one line containing an integer - the number of operations which can be performed on the given set of points until there are no more points to delete.

Examples

Input

aabb


Output

2


Input

aabcaa


Output

1

Note

In the first test case, the first operation will delete two middle points and leave points "ab", which will be deleted with the second operation. There will be no points left to apply the third operation to.

In the second test case, the first operation will delete the four points in the middle, leaving points "aa". None of them have neighbors of other colors, so the second operation can't be applied.
#include <bits/stdc++.h>
using namespace std;
int L[1000006];
int R[1000006];
bool erased[1000006];
int sz = 0;
int V[1000006 * 2];
int sz2 = 0;
int nextt[1000006 * 2];
int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); ++i) {
    L[i] = i - 1;
    R[i] = i + 1;
    if (i and s[i - 1] != s[i])
      V[sz++] = i;
    else if (i + 1 < s.size() and s[i + 1] != s[i])
      V[sz++] = i;
  }
  R[s.size() - 1] = -1;
  int steps = 0;
  for (; sz; ++steps) {
    sz2 = 0;
    for (int i = 0; i < sz;) {
      int j = i;
      int li = L[V[j]];
      int LL = li;
      while (j < sz and li == L[V[j]]) {
        li = V[j++];
      }
      int RR = R[V[j - 1]];
      if (LL != -1) R[LL] = RR;
      if (RR != -1) L[RR] = LL;
      if (LL != -1) {
        nextt[sz2++] = LL;
      }
      if (RR != -1) {
        nextt[sz2++] = RR;
      }
      i = j;
    }
    sz2 = unique(nextt, nextt + sz2) - nextt;
    sz = 0;
    for (int j = 0; j < sz2; ++j) {
      int i = nextt[j];
      if (L[i] != -1 and s[L[i]] != s[i])
        V[sz++] = i;
      else if (R[i] != -1 and s[R[i]] != s[i])
        V[sz++] = i;
    }
  }
  cout << steps << endl;
  return 0;
}
