s = input()
n = len(s)

l = []

i = 0
ans = 0
while i < n-1:
	if s[i] != s[i+1]:
		ans += 1
		num = 2
		while True:
			if len(l) == 0:
				break
			left = l.pop()
			right = s[i+num]
			if left != right:
				ans += 1
				num += 1
			else:
				break
		i += num
	else:
		l.append(i)
		i += 1
print(2*ans)
