#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main() {
    string S;
    cin >> S;
    int res = 1e9;
    for(int i=0; i<S.size(); ++i) {
        for(int j=i+1; j<S.size(); ++j) {
            for(int k=j+1; k<S.size(); ++k) {
                if(S[i] == 'c' && S[j] == 'w' && S[k] == 'w') {
                    res = min(res, k-i+1);
                }
            }
        }
    }
    if(res == 1e9) {
        cout << -1 << endl;
    } else {
        cout << res << endl;
    }
}