909_D. Colorful Points
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.
```python
name = input()

blocks = []
now = name[0]
counter = 1
for x in range(1, len(name)):
    if name[x] != now:
        blocks.append((now, counter))
        now = name[x]
        counter = 1
    else:
        counter += 1
blocks.append((now, counter))

counter = 0
temp = []
while len(blocks) > 1:
    counter += 1
    temp = []
    (x, y) = blocks[0]
    if y > 1:
        temp.append((x, y - 1))
    for s in range(1, len(blocks) - 1):
        (x, y) = blocks[s]
        if len(temp) > 0:
            (tempx, tempy) = temp[-1]
            if y > 2:
                if x != tempx:
                    temp.append((x, y - 2))
                else:
                    temp[-1] = (x, tempy + y - 2)
        else:
            if y > 2:
                temp.append((x, y - 2))

    (x, y) = blocks[-1]
    if len(temp) > 0:
        (tempx, tempy) = temp[-1]
        if y > 1:
            if x != tempx:
                temp.append((x, y - 1))
            else:
                temp[-1] = (x, tempy + y - 1)
    else:
        if y > 1:
            temp.append((x, y - 1))
    blocks = temp

print(counter)

```