In late January 2020, SnowballSH arrived in Chicago just a few days before international flights were cancelled. In 2021, he decided to attend Whitney M. Young Magnet High School after missing the Northside cutoff by exactly one point. Perhaps he was destined to be here?
SnowballSH loves the string "WY".
Given a string $$$s$$$ of length $$$n$$$, please help SnowballSH count the number of ordered pairs $$$(i, j)$$$, where $$$1 \le i \lt j \le n$$$, such that $$$s_i =$$$ W and $$$s_j =$$$ Y.
The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^6$$$).
The second line contains a string $$$s$$$ of length $$$n$$$.
It is guaranteed that $$$s$$$ contains only uppercase Latin alphabets.
Output a single integer, the number of ordered pairs $$$(i, j)$$$, where $$$1 \le i \lt j \le n$$$, such that $$$s_i =$$$ W and $$$s_j =$$$ Y.
20WYMATHTEAMNOTWYOMING
3
21YWWYYYWWWWYYYYYWWWWWW
36
For the first test, the desired pairs are $$$(1,2)$$$, $$$(1,15)$$$, and $$$(14,15)$$$, so the answer is $$$3$$$.
| Название |
|---|


