def pred(s, i, j)
  (s[i] == '0' && s[j] == '1') || (s[i] == '1' && s[j] == '0')
end

def func(s, i)
  j = i + 1
  
  while (i >= 0) && (j < s.size) do
    if pred(s, i, j) then
      s[i] = s[j] = 'x'
    end
    
    i -= 1
    j += 1
  end
  
  return s
end

def main(argv)
  s = gets.chomp
  n = s.size
  
  i = 0
  while i < (n - 1) do
    if pred(s, i, i + 1) then
      s = func(s, i)
    end
    
    i += 1
  end
  
  puts (n - s.delete('x').size).to_s
end

if self.to_s == 'main' then
  main(ARGV)
end