def deletePoints(s):
	r=""
	for i in range(len(s)-1):
		if s[i]==s[i+1]:
			r+=s[i]
			if i==len(s)-2:
				r+=s[i+1]
	return r


s=input()
c=0
while deletePoints(s)!=s:
	s=deletePoints(s)
	c+=1
print(c)
