// yukicoder: No.346 チワワ数え上げ問題 // 2019.4.15 bal4u #include #if 1 #define gc() getchar_unlocked() #else #define gc() getchar() #endif int ins(char *s) { char *p = s; do *s = gc(); while (*s++ > ' '); *--s = 0; return s - p; } char S[100005]; int main() { int w; long long ans; char *p; p = S + ins(S), w = 0, ans = 0; while (--p >= S) { if (*p == 'w') w++; else if (*p == 'c') ans += w*(w-1) >> 1; } printf("%lld\n", ans); return 0; }