s = gets.chomp.split("")

old_count = -1
count = 0

while old_count != count
	i = 0
	next_s = []
	old_count = count
	while s.size - 1 > i 
		if s[i] != s[i+1] then
			i += 2
			count += 2
		else
			next_s << s[i]
			i += 1
		end
	end
	if i == s.size - 1 then
		next_s << s[i]
	end
	
	s = next_s
end

puts count
