Problem Statement
Skenu constructed a building that has $N$ floors. The building has an elevator that stops at every floor.
There are buttons to control the elevator, but Skenu thoughtlessly installed only one button on each floor - up or down. This means that, from each floor, one can only go in one direction. If $S_i$ is U, only "up" button is installed on the $i$-th floor and one can only go up; if $S_i$ is D, only "down" button is installed on the $i$-th floor and one can only go down.
The residents have no choice but to go to their destination floors via other floors if necessary. Find the sum of the following numbers over all ordered pairs of two floors $(i,j)$: the minimum number of times one needs to take the elevator to get to the $j$-th floor from the $i$-th floor.
Constraints
$2 ≤ |S| ≤ 10^5$$S_i$is eitherUorD.$S_1$isU.$S_{|S|}$isD.
Input
The input is given from Standard Input in the following format:
S_1S_2...S_{|S|}
Output
Print the sum of the following numbers over all ordered pairs of two floors $(i,j)$: the minimum number of times one needs to take the elevator to get to the $j$-th floor from the $i$-th floor.
样例
UUD
7
UUDUUDUD
77
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。