import sys
input = sys.stdin.readline
s=str(input())
n=len(s)
Ans=[]
c=0
prev=None
while c<=n-3:
  s1,s2,s3=s[c],s[c+1],s[c+2]
  if s1!=prev:
    Ans.append(c+1)
    c+=1
    prev=s1
  else:
    Ans.append(c+2)
    c+=2
    prev=s1+s2
ans=len(Ans)
if n==1:
  print(1)
elif n==2:
  if s[0]!=s[1]:
    print(2)
  else:
    print(1)
elif n-Ans[-1]==3:
  s1,s2,s3=s[-3],s[-2],s[-1]
  if prev!=s1:
    if s1!=s2:
      if s2!=s3:
        print(ans+3)
      else:
        print(ans+2)
    else:
      print(ans+2)
  elif s2!=s3:
    print(ans+2)
  else:
    print(ans+1)
elif n-Ans[-1]==2:
  s1,s2=s[-2],s[-1]
  if prev!=s1 and s1!=s2:
    print(ans+2)
  else:
    print(ans+1)
else:
  print(ans+1)
