let s = stdin.ReadLine()

// 出現回数リストを作る
let folder (count, before, chunkList) (i,next) = 
    match i with 
    | 0 -> 1, next, chunkList // 初期処理
    | _ when i=s.Length-1 -> // 末尾処理
        match next = before with 
        | true -> count + 1, next , (before, count+1) :: chunkList 
        | false -> 1, next, (next, 1) :: (before, count) :: chunkList
    | _ ->
        match next = before with
        | true -> count + 1, next, chunkList
        | false -> 1, next,(before ,count) :: chunkList 

let appearanceList =
    s.ToCharArray()|> Array.mapi(fun i x -> i, x) |> Array.fold folder (0, '#', []) |> fun (_, _ , list) -> list |> List.rev

// 出現回数リストを元にした処理
appearanceList |> List.chunkBySize 2 
|> List.map (function
| [(c1,i1);(c2,i2)] -> 
    let (i1, i2)=
        if i2 > i1 then int64 i2, int64 i1 else int64 i1, int64 i2
    i1 *(i1 + 1L) / 2L + (i2 - 1L ) * i2 / 2L
| [(c,i)] ->
    let i = int64 i
    i * (i + 1L) / 2L)
|> Seq.sum
|> stdout.WriteLine