def delete():
  toDel = set()
  for b in range(len(string)):
    if b != 0:
      if string[b] != string[b-1]:
        toDel.add(b-1)
    elif b != len(string)-1:
      if string[b] != string[b+1]:
        toDel.add(b+1)
  for c in sorted(toDel,reverse=True):
    string.pop(c)
string = list(input())
length = 0
count = 0
while length-len(string):
  length = len(string)
  delete()
  count+= 1
print(count-1)