S = list(map(str, input()))
len_S_orig = len(S)
while True:
  #print('-----')
  #print(S)
  i = 1
  while i<= len(S)-1:
    #print(i)
    if S[i-1] != S[i]:
      S[i-1] = 'x'
      S[i] = 'x'
      i += 2
    else:
      i += 1
      pass

  # del all 'x's from the list 
  len_S_before = len(S)
  #print(S)
  S = [si for si in S if si != 'x']
  len_S_after = len(S)
  #print(S)
  if len_S_before == len_S_after:
    break
  
print(len_S_orig - len(S))