s = gets.chomp.split("")
s_length = s.length
stack = []
i = -1

while s.length > 0
  stack.push(s.pop)
  i += 1
  if i == 0
    next
  elsif stack[i] != stack[i-1]
    stack.pop(2)
    i -= 2
  end
end

puts s_length - stack.length