let s = stdin.ReadLine()

// 出現回数リストを作る
let folder (count, before, chunkList) next = 
    match before with 
    | '#' -> 1, next, chunkList // 初期処理
    | x  when x=next -> count+1, next, chunkList
    | _ -> 1, next, (before,count)::chunkList

let chunkList = 
    (s+"#").ToCharArray() |> Seq.fold folder (0, '#', []) 
    |> fun (_, _, list) -> list |> List.rev, list.Head, list |> List.rev |> List.head 
    |> fun (x,_,_) -> x

// 出現回数リストを元にした処理
chunkList |> 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