s = input()
n = len(s)
ans = 0
pos = 0
is_len_1 = False
is_now = ""
while pos < n:
    if is_len_1:
        if s[pos - 1] == s[pos]:
            pos += 2
            is_len_1 = False
            is_now = s[pos : pos + 2]
        else:
            pos += 1
            is_now = s[pos : pos + 1]
    else:
        pos += 1
        is_len_1 = True
        is_now = s[pos : pos + 1]
    ans += 1
# 末尾の連続列を考える
pos = n - 1
len_tail = 1
while pos > 0:
    if s[pos] == s[pos - 1]:
        len_tail += 1
        pos -= 1
    else:
        break
if len_tail % 3 == 2:
    ans -= 1
print(ans)
