<?php
$stdin = trim(fgets(STDIN));
for ($i = 0; $i < strlen($stdin); ++$i) {
    $arr[] = substr($stdin, $i, 1);
}

$len = count($arr);
$cnt = 0;
$remove_keys = [];
$before_key = null;

foreach ($arr as $k => $v) {
    if ($k > 0) {
        $before_key = get_before_key($k, $remove_keys);

        if (isset($arr[$before_key]) && $v != $arr[$before_key]) {
            $cnt = $cnt + 2;
            unset($arr[$k]);
            unset($arr[$before_key]);
            $remove_keys[] = $k;
            $remove_keys[] = $before_key;
        }
    }
}

function get_before_key($key, $remove_keys)
{
    $retval = $key - 1;

    if (count($remove_keys) > 0) {
        $rsort = $remove_keys;
        rsort($rsort);
        $max = max($rsort);

        if (($key - 1) != $max) {
            $retval = $key - 1;
        } else {
            foreach ($rsort as $k => $v) {
                $retval = $v - 1;
                if (($v - 1) != $rsort[$k + 1]) {
                    break;
                }
            }
        }
    }

    return $retval;
}

echo $cnt;