s = input()
z = []
last = None
for c in s :
    if last == c :
        z[-1] += 1
    else :
        last = c
        z.append(1)
a = 0
flag = False
for v in z :
    if flag :
        a += (v*2+2)//3
        flag = False
    else :
        a += (v*2+1)//3
        if v%3 == 2 :
            flag = True
        else :
            flag = False
print(a)