a=list(input())
K=0
while 1:
    if len(a)==0 or len(a)==1:
        break
    b=[]
    if a[0] != a[1]:
        b.append(0)
    for i in range(len(a)-1):
        if a[i] != a[i+1]:
            b.append(i+1)
    if len(b)==0:
        break
    for j in b:
        a[j]='A'
    i1=0
    while i1<len(a):
        if a[i1]=='A':
            del(a[i1])
        else:
            i1+=1
    K+=1
print(K)