#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <list>
#include <typeinfo>
using namespace std;
#define REP(a,b) for(long long a = 0;a < b;++a)
int main() {
	string hoge;
	cin >> hoge;
	int ans = 300;
	for (int i = 0;i < hoge.length()-2;++i) {
		if (hoge[i] == 'c') {
			for (int q = i+1;q < hoge.length()-1;++q) {
				if (hoge[q] == 'w') {
					for (int j = q + 1;j < hoge.length();++j) {
						if (hoge[j] == 'w') {
							ans = min(ans, j - i+1);
						}
					}
				}
			}
		}
	}
	if (ans == 300) {
		cout << "-1" << endl;
	}
	else {
		cout << ans << endl;
	}
}
//thank you for reading my code!