#include #include using namespace std; int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int wCnt; //ワーク char str[100] = { 0 }; //文字列 char *now, *search; //現在位置 int work = 0; int ans = 100; //入力 cin >> str; int loop = strlen(str); search = str; //文字捜索開始 while(loop) { //Cを見つける if(*search == 'c') { //Cの位置を記憶 now = search; ++work; //wカウント2 wCnt = 2; //文字カウントスタート while(wCnt) { //現在位置カウンタ 進め ++now; //文字数も進める ++work; //wを見つけたら if(*now == 'w') { //カウントダウン --wCnt; } //文字が無くなったら 抜ける if(!(*now)) { work = 100; break; } } //文字カウント最小値更新 if(work < ans) { ans = work; } work = 0; } ++search; --loop; } cout << ((ans == 100) ? (-1) : (ans)) << endl; return 0; }