s=input()
s=list(s)
i=[]
count=0
s.insert(0, '1')
s.append('1')
for k in range(1,(len(s)-1)):
    if ( s[k]!=s[k-1] or s[k]!=s[k+1] ):
        i.append(k)
while len(i)!=0:
    p=i[:]
    count+=1
    t=0
    for k in p:
        s.pop(k-t)
        t+=1
    i=[]
    for k in range(1,(len(s)-1)):
        if ( s[k]!=s[k-1] or s[k]!=s[k+1] ):
            i.append(k)
print(count)