#include #include using namespace std; int main() { string S; int cwwFlag[2] = { 0,0 }; int cwwCounter[2] = { 0,0 }; int cwwMin = 101; cin >> S; for (int i = 0; i < S.length(); i++) { if (S[i] == 'c') { if (cwwFlag[0] == 1) cwwCounter[0] = 0; else cwwFlag[0] = 1; } if (cwwFlag[0] == 1) cwwCounter[0]++; if (cwwFlag[1] == 1) cwwCounter[1]++; if (S[i] == 'w') { if (cwwFlag[1] == 1) { if (cwwCounter[1] < cwwMin) cwwMin = cwwCounter[1]; cwwCounter[1] = 0; cwwFlag[1] = 0; } if (cwwFlag[0] == 1) { cwwCounter[1] = cwwCounter[0]; cwwFlag[1] = 1; cwwCounter[0] = 0; cwwFlag[0] = 0; } } } if (cwwMin == 101) cwwMin = -1; cout << cwwMin << endl; return 0; }