Bessie the cow found an inscription carved into a large stone in the middle of her favorite grazing field. The text is written in an ancient language whose alphabet has only the three characters C, O, and W. Bessie cannot read the text, but she notices that C, O, and W in that order spell her favorite word, COW, so she wants to know how many times COW appears in the text.
Bessie does not mind other characters sitting between the C, the O, and the W. Only the order matters. She also does not mind when two different occurrences of COW share some letters. For example, COW appears once in CWOW, twice in CCOW, and eight times in CCOOWW.
Given the text of the inscription, count how many times COW appears.
The first line contains an integer N (N≤105).
The second line contains a string of N characters, each of which is C, O, or W.
Print the number of times COW appears as a subsequence of the input string. The three letters of the subsequence do not have to be contiguous.
The answer can be very large, so use 64-bit integers for the calculation (long long in C++, long in Java).