inputs = STDIN.gets.chomp.split('')
len = inputs.length

def scan!(arr)
  i = 0
  flag = false
  while i < arr.length-1
    if arr[i] != arr[i+1]
      arr.delete_at(i)
      arr.delete_at(i)

      i -= 1
      flag = true
    end
    i += 1
  end
  flag
end

i = 0
while true do
  break unless scan! inputs
end


puts len - inputs.length
