function main(input) {
    const args = input.split(' ');
    var cubes_words = args[0];
    var cubes = [];
    var length = cubes_words.length;

    for(var i = 0; i < length; i++) {
        cubes.push(cubes_words.charAt(i));
    }

    isRoop = false;
    var ans = 0;

    var test_front;
    var test_front_no;
    var test_back;
    var test_back_no;
    var i = 0

    while(1) {
        while (i < length - 1) {
            if (cubes[i] !== null) {
                test_front = cubes[i];
                test_front_no = i;
                i++;
                while (cubes[i] === null && i < length) {
                    i++;
                }
                test_back = cubes[i];
                test_back_no = i;
                if(test_front !== test_back) {
                    ans += 2;
                    cubes[test_front_no] = null;
                    cubes[test_back_no] = null;
                    isRoop = true;
                }
            } else {
                i++;
            }
        }
        if(isRoop) {
            isRoop = !isRoop;
            i = 0;
        } else {
            break;
        }
    }

    console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
