import Data.List

main = getLine >>= print . solve 0 . map length . group

solve _ [] = 0
solve prv (x:xs) = (if prv * (mod x 3) == 2 then 1 else 0) + (div (x - 1) 3) + (div x 3) + 1 + solve (if (1 - prv) * (mod x 3) == 2 then 1 else 0) xs