from itertools import groupby
l=[len(list(g)) for k,g in groupby(input())]
ans=0
k=[]
for i in l:
	if i==1:
		ans+=1
		k.append(0)
	else:
		ans+=(i//3)*2
		k.append(i%3)
for i in range(len(k)-1):
	if k[i]==1:
		ans+=1
	elif k[i]==2:
		if k[i+1]==2:
			ans+=2
			k[i+1]=1
		else:
			ans+=1
if k[-1]>0:
	ans+=1
print(ans)