import Data.Bool (bool)

main :: IO ()
main = do
  s <- getLine
  print $ unify s

unify :: String -> Int
unify s = 2 * fst (unify' (0, s))
  where
    unify' (k, (x : y : ls))
      =
        if x == y
          then
            let (k', ls') = unify' (k, y : ls) in
              case ls' of
                []
                  ->
                    (k', [x])
                y' : ls''
                  ->
                    if x == y'
                      then
                        (k', x : y' : ls'')
                      else
                        (k' + 1, ls'')
          else unify' (k + 1, ls)
    unify' t = t
