s = input()
num = len(s)
ans = 0
befor = ""
ss = s

count = 0

while True:
  if befor != ss[:1]:
    befor = ss[:1]
    ss = ss[1:]
  else:
    befor = ss[:2]
    ss = ss[2:]
  
  ans += 1
  count += 1
  
  if len(set(ss)) == 1:
    a = len(ss)
    ans += (a // 3) * 2
    if a % 3 != 0:
      ans += 1
    break
  
  
  if len(ss) <= 0:
    break
  if count > 1000000:
    break
  


print(ans)
