S_array = input()

lastIndex = len(S_array) -1
lastChar = S_array[len(S_array)-1]
while lastIndex > 0 and S_array[lastIndex-1] == lastChar:
    lastIndex -= 1

nextIndex = 0
k_counter = 0
was_prev_1 = False

while nextIndex < lastIndex:
    if was_prev_1:
       if S_array[nextIndex] == S_array[nextIndex-1]:
           was_prev_1 = False
           nextIndex += 2
       else:
           was_prev_1 = True
           nextIndex += 1
    else:
        was_prev_1 = True
        nextIndex += 1
    k_counter += 1

remains = len(S_array) - 1 - nextIndex + 1
if remains % 3 == 0:
    k_counter += remains / 3
elif remains % 3 == 1:
    k_counter += (remains - 1) / 3 + 1
elif remains % 3 == 2:
    k_counter += (remains - 2) / 3 + 1

print(int(k_counter))
