S = input()
cnt = 1
buf = [0]
tmp = []


for a,b in zip(list(S)[1:],list(S)[:-1]):
#    print(a,b)
    buf[-1] = cnt
    if a == b: 
        cnt += 1
        buf[-1] = cnt
    else:
        buf.append(cnt)
        cnt = 1
#print(buf)
res = 0

for n in buf:
    if n < 3:
        res += 1
    else:
        res += (n//3)*2+(n%3)
#    print((n//3)*2+(n%3))
print(res)