COW
#include<iostream>
using namespace std;
int main(){
long long int c,o,w;
c = o = w = 0;
int n;
string alls;
cin >> n >> alls;
for(auto i : alls){
if(i == 'C') c ++;
if(i == 'O') o += c;
if(i == 'W') w += o;
}
cout << w;
}