#include int main(int argc, char const *argv[]) { /* code */ char str[256]; int wp = 0, wp_c = 0, i = 0, j = 0; int flag = 0, cnt = 256; int start[256] = {0}; while(fscanf(stdin, "%c", &str[wp]) != EOF){ wp++; } //printf("wp = %d\n", wp); for(i = 0; i < wp; i++){ if(str[i] == 'c'){ start[wp_c++] = i; //printf("start[%d] = %d\n", wp_c - 1, i); } } for(i = 0; i < wp_c; i++){ j = 0; while(start[i] + j++ < wp){ if(str[start[i] + j] == 'w'){ while(start[i] + j++ < wp){ if(str[start[i] + j] == 'w'){ if(cnt > j){ cnt = j + 1;; flag = 1; } break; } } break; } } } if(flag == 1){ fprintf(stdout, "%d\n", cnt); }else{ fprintf(stdout, "-1\n"); } return 0; }