#include #include #include #include int fact(int n){ return n == 0 ? 0 : fact(n-1) + n; } int chiwawa(std::string const& input, int start = 0){ auto c = input.find('c', start); if( c == std::string::npos || c >= input.size() ) return 0; auto ws = std::count(std::begin(input)+c, std::end(input), 'w'); auto result = fact(ws-1) + chiwawa(input, c+1); return result; } int main(){ std::string str; std::cin >> str; auto result = chiwawa(str); std::cout << result << std::endl; return 0; }