
import qualified Data.ByteString.Char8 as B

solv bs = go bs [] 0 where
  go bs stk n
    | B.null bs = n
    | null stk = go (B.tail bs) [B.head bs] n
    | B.head bs/=head stk = go (B.tail bs) (tail stk) (n+2)
    | otherwise = go (B.tail bs) (B.head bs:stk) n

main = do
  xs <- B.getLine
  print $ solv xs
