import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

ans = 0

s = input()
tmp = s[0]
cnt = 1
back = False
for c in s[1:]:
    if tmp == c:
        cnt += 1
    else:
        # print(cnt)
        ans += (cnt // 3) * 2
        cnt = cnt % 3
        if cnt == 1:
            ans += 1
            back = False
        elif cnt == 2:
            if back:
                ans += 2
                back = False
            else:
                ans += 1
                back = True
        else:
            back = False

        cnt = 1
        tmp = c


# ans += (cnt // 3) * 2
# cnt = cnt % 3
# if cnt == 1:
#     ans += 1
#     back = False
# elif cnt == 2:
#     if back:
#         ans += 2
#         back = False
#     else:
#         ans += 1
#         back = True
# else:
#     back = False


print(ans)