#include #include #include using namespace std; int main() { string s; regex regex("c[^w]*w[^w]*w"); smatch match; int min = 100; cin >> s; sregex_token_iterator first(begin(s),end(s), regex); sregex_token_iterator last; if (first == last) { cout << -1 << endl; return 0; } while (first != last) { if (first->length() < min) { min = first->length(); } ++first; } cout << min << endl; return 0; }