def func(s)
  if s == '' then
    return s
  end
  
  (0...(s.size - 1)).each do |i|
    if s[i] != s[i + 1] then
      s.slice!(i, 2)
      break
    end
  end
  
  return s
end

def main(argv)
  s = gets.chomp
  c = 0
  
  while true do
    t = func(s.dup)

    if s == t then
      break
    end
    
    c += 1
    s = t
  end

  puts (c * 2).to_s
end

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