#include <algorithm>
#include <iostream>
#include <regex>
#include <string>

using namespace std;

int main(int argc, const char* argv[])
{
	string S;
	cin >> S;
	//regex re("c[^c]*w.*w");
	//	NOTE 全体マッチとなるため
	regex re("(c[^c]*?w.*?w).*");
	smatch match;
	int l = 101;

	int index;
	while ((index = S.find("c")) != -1) {
		S.erase(S.begin(), S.begin() + index);
		if (regex_match(S, match, re)) {
			//	NOTE 0:entire match, 1~: () matched
			l = min(l, (int)match.length(1));
			S.erase(S.begin(), S.begin() + 1);
		}
	}
	if (l == 101) {
		l = -1;
	}
	cout << l << endl;
	return 0;
}