def main():
    s = input()
    arr = []
    curr = s[0]
    count = 0
    for i in s:
        if i == curr:
            count += 1
        else:
            arr.append(count)
            curr = i
            count = 1

    arr.append(count)

    #print(arr)
    ans = 0
    for i in range(len(arr)):
        ans += 2*(arr[i]//3)
        arr[i] = arr[i]%3

    #print(arr)
    for i in range(len(arr)-1):
        if arr[i] == 2 and arr[i+1] == 2:
            ans += 2
            arr[i+1] = 1
        elif arr[i] > 0:
            ans += 1

    if arr[-1] > 0:
        ans += 1

    print(ans)


main()
