#include #include #include #include #include int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); std::string s; std::cin >> s; std::stack wposStack; std::string::size_type minLen = std::numeric_limits::max(); for (std::string::size_type i = s.length() - 1; i != static_cast(-1); i--) { switch (s[i]) { case 'c': if (wposStack.size() > 1) { wposStack.pop(); minLen = std::min(minLen, wposStack.top() - i + 1); wposStack.pop(); } break; case 'w': wposStack.push(i); break; } } printf("%d\n",minLen == std::numeric_limits::max() ? -1 : minLen); return EXIT_SUCCESS; }