S=input()
lenS=len(S)
ls=[]
ls.append(S[0])
for i in range(1,lenS):
	if len(ls)==0:
		ls.append(S[0])
		continue
	tmp=ls.pop(-1)
	if tmp==S[i]:
		ls.append(tmp)
		ls.append(S[0])
print(lenS-len(ls))



