#include "bits/stdc++.h" using namespace std; int main() { string S; cin >> S; int bC = -1, ans = 1000; bool C = false, W = false; for (int i = 0; i < S.size(); i++) { if (!C && S[i] == 'c') { bC = i; C = true; } if (C && !W && S[i] == 'w') { W = true; } else if (C && W && S[i] == 'w') { ans = min(ans, i - bC + 1); i = bC; C = false; W = false; } } if (ans == 1000) ans = -1; cout << ans << endl; }