#include #include using namespace std; int main() { string s; cin >> s; int n = s.size(); int w1 = n; int w2 = n; int res = n + 1; for (int i = n - 1; i >= 0; i--) { if (s[i] == 'w') { w2 = w1; w1 = i; } else if (s[i] == 'c'){ if (w1 != n) { res = min(res, w2 - i + 1); } } } if (res == n + 1) res = -1; cout << res << endl; return 0; }