import Data.List
import Data.Char

result s = sum . map (digitToInt . fst) . filter (uncurry (==)) $ zip (drop 1 . cycle $ s) s

-- exemple cases
main = mapM_ (putStrLn . show . result) $ ["1122", "1111", "1234", "91212129"]