def delpoints(f):
	r = ""
	n = len(f)
	if n==1:
		return f
	for i in range(len(f)):
		if i+1<n and i-1>=0 and f[i]==f[i+1] and f[i]==f[i-1]:
			r+=f[i]
		elif i+1<n  and f[i]==f[i+1] and i-1<0:
			r+=f[i]
		elif i-1>=0 and f[i]==f[i-1] and i+1>n-1:
			r+=f[i]
	return r

y = raw_input()
sum = 0
g = y
while(True):
	x = g
	g = delpoints(g)
	if g=="":
		sum+=1
		break
	if x==g:
		break
	sum+=1
	print g
	
print sum


