import sys
from itertools import groupby

input = sys.stdin.readline
input_list = lambda: map(int, input().split())

dup = lambda x,y: ((x)+(y)-1)//(y)

def solve():
  s = input()
  
  groups = []  
  for _, g in groupby(s):
    groups += [list(g)]

  ans = 0
  flag = False
  for group in groups:
    n = len(group)
    c = (n-1)//3 * 2
    o = n%3
    if o == 0:
      d = 2
    elif o == 1:
      d = 1
      flag = False
    elif o == 2 and flag:
      d = 2
      flag = False
    elif o == 2 and not flag:
      d = 1
      flag = True
    ans += c + d
    print(group, c+d, file=sys.stderr)

  print(ans)

solve()