#include //cin, cout #include //vector #include //sort,min,max,count #include //string,getline, to_string #include //abs(int) #include //swap, pair #include //deque #include //INT_MAX #include //bitset #include //sqrt, ceil. M_PI, pow, sin #include //fixed #include //setprecision #include //stringstream using namespace std; int main() { string S; cin >> S; if (S.length() < 3) { cout << -1 << endl; return 0; } int min = INT_MAX; for (unsigned int i = 0; i < S.length() - 2; i++) { if (S[i] == 'c') { for (unsigned int j = i + 1; j < S.length() - 1; j++) { if (S[j] == 'w') { for (unsigned int k = j + 1; k < S.length(); k++) { if (S[k] == 'w') { int temp = k - i + 1; if (min > temp) { min = temp; } break; } } break; } } } } if (min == INT_MAX) { cout << -1 << endl; } else { cout << min << endl; } return 0; }