#include using namespace std; bool is_cww (const string &s) { bool c = false, w = false, ww = false; for (const char &ch : s) { if (!c and !w and !ww) { if (ch == 'c') c = true; } else if (c and !w and !ww) { if (ch == 'w') w = true; } else if (c and w and !ww) { if (ch == 'w') ww = true; } } return (c and w and ww); } int main() { string s; cin >> s; int ans = 111; for (int i = 0; i < s.length(); i++) { for (int len = 1; i + len <= s.length(); len++) { if (is_cww(s.substr(i, len))) ans = min(ans, len); } } if (ans == 111) ans = -1; cout << ans << '\n'; return 0; }