#include using namespace std; #define REP(i, n) for(int i = 0; i < n; i++) int main() { string s; cin >> s; vector c, w; REP(i, s.length()) { if (s[i] == 'c') c.push_back(i); if (s[i] == 'w') w.push_back(i); } int ans = INT_MAX; REP(i, int(c.size())) { REP(j, int(w.size()) - 1) { if (w[j] > c[i]) { ans = min(ans, w[j + 1] - c[i] + 1); break; } } } cout << ((ans == INT_MAX) ? -1 : ans) << endl; return 0; }