def main():
	s = input()
	s+=" "
	n=len(s)

	ans=0
	c=0
	m=0
	a=s[0]
	for i in range(n):
		if s[i]!=a:
			if c%3==0:
				ans+=(c//3)*2;
			else:
				ans+=1+(c//3)*2
			if m==2 and c%3==2:ans+=1;m=0
			else:m=c%3
			c=1
		else:
			c+=1
		a=s[i]
	print(ans)
main()
