#include #define rep(i,n) for(int i=0; i<(n); i++) using namespace std; typedef long long ll; int main(){ string s; cin>>s; regex re(R"(c\w*?w\w*?w)"); smatch match{}; if(regex_search(s, re)==false){ cout << "-1" << endl; return 0; } vector v; while(regex_search(s, match, re)){ string r=match[0]; int w=r.size(); v.push_back(w); s = match.suffix(); } sort(v.begin(), v.end()); cout << v[0] << endl; }