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 {
	if val, ok := memo[s]; ok {
		return val
	}

	max := 0

	for i := 0; i < len(s)-1; i++ {
		if s[i] != s[i+1] {
			ss := s[0:i] + s[i+2:len(s)]
			result := manip(ss, t+1)
			if result > max {
				max = result
			}
		}
	}
	if max == 0 {
		return t
	}

	memo[s] = max
	return max
}
