#include #include #include #include int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); std::string s; std::cin >> s; std::string::size_type pos = -1; if ((pos = s.find('c', pos + 1)) == std::string::npos) { std::cout << -1 << std::endl; return EXIT_SUCCESS; } else { while (pos + 1 < s.length() && s[++pos] == 'c'); pos--; } std::array ps{pos, 0, 0}; int idx = 1; for (const auto& c : {'w', 'w'}) { if ((pos = s.find(c, pos + 1)) == std::string::npos) { std::cout << -1 << std::endl; return EXIT_SUCCESS; } else { ps[idx++] = pos; } } std::cout << (ps[2] - ps[0] + 1) << std::endl; return EXIT_SUCCESS; }