S = gets.split('')

$arr = []
$count = 0

def f(arr)
  start_count = $count
  b_s = ''
  is_del = false
  tmp_arr = []
  arr.each do |c_s|
    if b_s != '' && b_s != c_s && !is_del
      $count += 1
      tmp_arr.pop()
      is_del = true
    else
      tmp_arr << c_s
      is_del = false
    end
    b_s = c_s
  end
  return start_count if start_count == $count

  f(tmp_arr)
end

puts f(S) * 2