# 奇数個(n)連続なら、(n+1)//2個に分けられる
# 1 => 1
# 3 => 1, 2 => 2
# 5 => 2, 1, 2 => 3
# 7 => 1, 2, 1, 2, 1 => 5
# 9 => 1, 2, 1, 2, 1, 2 => 6
# 11 => 2, 1, 2, 1, 2, 1, 2 = 7
# 偶数個(n)連続なら、
# 2 => 1, 1+a or 1+a, 1 => 2 
# 4 => 1, 2, 1 => 3
# 6 => 1, 2, 1, 2 => 4
# 8 => 1, 2, 1, 2, 1, 1+a or 2, 1, 2, 1, 2 => 6 or 5
# 偶数かつ3の倍数ー1の時は2通りあって、(n+2)//2 or (n+2)//2+2、そうでない時は(n+2)//2
# 特殊な偶数も(n+2)//2個とみなせるが、特殊な偶数が連続した場合はそれ＋1

s = list(input())
l = len(s)

mae= s[0]
re = 0
tot = []
for i in range(1, l):
    re += 1
    if mae != s[i]:
        tot.append(re)
        re = 0
        mae = s[i]
    else:
        mae = s[i]
tot.append(max(re, 1))

ans = 0
lt = len(tot)
flag = False

for i in range(lt):
    n = tot[i]
    if n == 2:
        ans += 1
    else:
        ans += (n+2)//2
    if n % 2 == 1:
        ans += n//6
    if flag:
        if n%6 == 2:
            ans += 1
            flag = False
        else:
            flag = False
    else:
        if n%6 == 2:
            flag = True

print(ans)
    