#include using namespace std; const int INF = 10000000; typedef long long ll; int main() { string s; cin >> s; vector c; vector w; for (int i = 0; i < s.size(); ++i) { if (s[i] == 'c') c.push_back(i); if (s[i] == 'w') w.push_back(i); } int ans = INF; for (int i = 0; i < c.size(); ++i) { int cnt = 0; for (int j = 0; j < w.size(); ++j) { if (w[j] > c[i]) { cnt++; if (cnt == 2) { ans = min(ans, w[j] - c[i] + 1); } } } } if (ans == INF) puts("-1"); else cout << ans << '\n'; return 0; }