import sys
s = input().strip()
l = len(s)
a = [0]*l
count=0
cont=True
while(cont):
    cont=False
    last = 0
    for i in range(l):
        if a[i]==-1:
            continue
        if s[i]!=s[last]:
            a[i]=-1
            a[last]=-1
            cont=True
        last=i
    count+=1
print(count-1)