ss=list(str(input()))
s=ss.copy()
c=0
a,b=s[0],s[-1]
while(True):
	f=0
	r=[]
	f=0
	if len(s)<2:
		break
	for i in range(len(s)):
		
		if i==0:
			if s[0]==s[1]:
				r.append(s[0])
		elif i==len(s)-1:
			if s[len(s)-1]==s[len(s)-2]:
				r.append(s[len(s)-1])
				
		elif s[i]==s[i-1] and s[i]==s[i+1]:
			r.append(s[i])
	#print(r)
	if len(r)==len(s):
		f=1
	s=r.copy()
	c+=1
	if f==1:
		break
	

print(c-1)

		
