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 i2, i1 else i1, i2
    i1*(i1+1)/2 + (i2-1)*i2/2
| [(c,i)] ->
    i * (i + 1) / 2)
|> Seq.sum
|> stdout.WriteLine