S = input()
list1 = []
cnt = 0
for i in range(len(S)-1):
  if S[i] == S[i+1]:
    if len(S) ==2:
      cnt =  2
    else:
      cnt += 1
  else:
    if cnt > 2: 
      list1.append(cnt)
      cnt = 0

if list1 == []:
  print(len(S) - cnt + 1)
else:
  for x in list1:
    cnt += x - 1
  print(len(S) - cnt)