S = input()
N = len(S)

cursol = -1
lst = []
for i in range(N - 1):
    if S[i] != S[i + 1]:
        lst.append(i - cursol)
        cursol = i
lst.append(i+1 - cursol)
#print(lst)

cnt = 0
for val in lst:
    if val <= 2:
        cnt += 1
    elif val % 3 == 0:
        cnt += (val // 3) * 2
    else:
        cnt += (val // 3) * 2 + 1
print(cnt)