#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
freopen("cowa.in","r",stdin);
freopen("cowa.out","w",stdout);
long long n,sum=0,m,sumc=0;
long long cnt=0;
cin>>n;
char ch;
getchar();
for (int i=1;i<=n;++i)
{
scanf("%c",&ch);
if (ch=='C') sumc++;
else if (ch=='O')
{
sum+=sumc;
}
else if (ch=='W')
{
cnt+=sum;
}
}
cout<<cnt;
}