package main

import (
	"fmt"
	"strings"
)

var result int

func delete2(array []string, i int) []string {
	tmp := make([]string, len(array))
	copy(tmp, array)
	if len(tmp)-1 >= i+2 {
		return append(tmp[:i], tmp[i+2:]...)
	}
	return tmp[:i]
}

func rec(array []string, try int) {
	for i := range array {
		if i >= len(array)-1 {
			if try > result {
				result = try
			}
		} else {
			if array[i] != array[i+1] {
				rec(delete2(array, i), try+1)
			}
		}
	}
	if try > result {
		result = try
	}
}

func main() {
	var S string
	fmt.Scan(&S)
	sList := strings.Split(S, "")
	result = 0
	rec(sList, 0)
	fmt.Println(result * 2)
}