#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); string s; cin >> s; int ans = 1e9; rep(i,int(s.size())) { if(s[i] == 'c') { int cnt = 0; for(int j = i + 1; j < int(s.size()); j++) { if(s[j] == 'w') cnt++; if(cnt == 2) { ans = min(ans, j - i + 1); break; } } } } cout << (ans == int(1e9) ? -1 : ans) << endl; }