#include #include #include using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int ans = 999,size; bool w_flag = false; string str; cin >> str; size = str.length(); for (int i = 0; i < size;i++) { if (str[i] == 'c') { for (int j = i + 1;j < size; j++) { if (str[j] == 'w') { if (w_flag == false) { w_flag = true; } else { ans = min(ans, j - i + 1); } } } w_flag = false; } } if (ans == 999) { cout << -1 << endl; } else { cout << ans << endl; } return 0; }