import sys

#+++++
		
def main():
	s = input()
	if len(s) == 1:
		return 1
	
	ls=list(s)
	cc=ls[0]
	count=1
	nl=[]
	for c in ls[1:]:
		if c == cc:
			count+=1
		else:
			nl.append(count)
			cc=c
			count=1
	nl.append(count)
	
	nnl=[]
	ret=0
	for i in nl:
		b = i % 3
		if b != 0:
			ret += 1
			
		k = i // 3
		ret += k* 2
		nnl.append(b)

	cc=1
	for i in nnl:
		#print(i,nnl,ret)
		if cc == 2 and i == 2:
			cc = 0
			ret +=1
		elif cc != 2 and i == 2:
			cc=2
		elif cc == 2 and i == 1:
			pass
		else:
			cc=0
	
	print(ret)

	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)