def removable(s):
	lst = []
	for i in range(0, len(s)-1):
		if s[i] != s[i+1]:
			lst.append(i)
	return lst

S = raw_input()
max = 0
queue = [[S, 0]]
while queue != []:
	now = queue.pop(0)
	removelist = removable(now[0])
	if removelist == []:
		if max < now[1]: max = now[1]
	else:
		for i in range(0, len(removelist)):
			queue.append([now[0][:removelist[i]]+now[0][removelist[i]+2:], now[1]+2])
			print queue

print max