package main

import "fmt"

func main() {
	var s string
	fmt.Scanln(&s)
	fmt.Println(manip(s, 0) * 2)
}

var memo = make(map[string]int)

func manip(s string, t int) int {
	for i := 0; i < len(s)-1; i++ {
		if s[i] != s[i+1] {
			ss := s[0:i] + s[i+2:len(s)]
			if val, ok := memo[ss]; ok {
				return val
			}
			result := manip(ss, t+1)
			memo[ss] = result
			return result
		}
	}
	return t

}
