from math import sqrt
s = str(input())
n = len(s)
k = 1
l = []
for i in range(n-1):
  if s[i] == s[i+1]:
    k += 1
  else:
    l.append(k)
    k = 1
l.append(k)
ans = 0
for j in range(len(l)-1):
  if l[j] == 0:
    1
  elif l[j] == 1:
    ans += 1
  else:
    start = int(sqrt(2*l[j]))
    while True:
      if (start**2-start)/2 < l[j] <= (start**2+start)/2:
        break
      else:
        start += 1
    cnt = 1
    if (start**2+start)/2 == l[j]:
      cnt = 0
    ans += start
    l[j+1] = l[j+1]-cnt
m = len(l)
start = int(sqrt(2*l[m-1])-1)
while True:
  if (start**2+start)/2 <= l[m-1] < (start**2+3*start+2)/2:
    break
  else:
    start += 1
ans += start
print(ans)