#include #include int num[100000]; char S[100001]; main(){ int sum = 0; int count = 0;//cの数 scanf("%s",S); for(int i = 0;i < strlen(S);i++){ if(S[i]=='c'){ num[count] = sum; count++; } if(S[i]=='w'){ sum++; } } long long ans = 0; for(int i = 0;i < count;i++){ int a = sum-num[i]; if(a >= 2){ ans += a*(a-1)/2; } } printf("%lld\n",ans); }