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 (f prv (mod x 3)) xs

f 0 0 = 0
f 0 1 = 0
f 0 2 = 1
f 1 0 = 1
f 1 1 = 0
f 1 2 = 0