structure A  = Array
structure C  = Char
structure CV = CharVector
structure I  = Int
structure L  = List
structure LI = LargeInt
structure S  = String
structure SC = StringCvt
structure T  = TextIO

fun scan rdr strm = SOME (SC.splitl (not o C.isSpace) rdr (SC.skipWS rdr strm))

fun next () = valOf (T.scanStream scan T.stdIn)

fun nextInt () = valOf (T.scanStream (I.scan SC.DEC) T.stdIn)

val () =
    let
        val s = ref (next ())
        val i = ref 0
        val cnt = ref 0
    in
        while !i < S.size (!s) - 1 do (
            if S.sub (!s, !i) <> S.sub (!s, !i + 1)
            then (cnt := !cnt + 2;
                  s := S.substring (!s, 0, I.max (!i, 0)) ^
                       S.substring (!s, I.min (!i + 2, S.size (!s) - 1), S.size (!s) - !i - 2);
                  i := I.max (!i - 1, 0))
            else i := !i + 1
        );
        print (I.toString (!cnt) ^ "\n")
    end
