#include <bits/stdc++.h>
//
using namespace std;
#define REP(i, n) for(int(i)=0;(i)<(n);++(i))

int main(){
    string s;
    cin >> s;

    regex re("c.*?w.*?w");
    cmatch match;
    cerr << "s = " << s << endl;

    int n = s.size();
    int res = -1;
    for(int i = 0; i < n; ){
        if(regex_search(s.c_str() + i, match, re)){
            auto m = match[0];

            int pos = i + match.position(0);
            int len = m.length();
            if(res < 0) res = len;
            res = min(res, len);

            cerr << "pos = " << setw(2) <<  pos << ", len = " << setw(2) << len << " : " << m << endl;
            i = pos + 1;
        } else break;
    }
    cout << res << endl;
    return 0;
}