s = input()
ans = 1
if(len(s) == 1):
  ans = 1
else:
  for i in range(len(s)):
    if(i == 0):
      ans += 1
      p = 0
    elif(s[i] != s[i-1]):
      ans += 1
      p = 0
    else:
      p += 1
      if(p == 3):
        ans += 1
        p = 0

print(ans)