#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define MAX_MOD 1000000007 #define REP(i,n) for(long long i = 0;i < n;++i) #define LONGINF 1000000000000000000 int main() { string n; cin >> n; int ans = 1000; REP(i, n.length()) { if (n[i] == 'c') { bool hoge = 0; for (int q = i + 1;q < n.length();++q) { if (n[q] == 'w') { if (hoge == 1) { ans = min(ans, (int)q - (int)i); goto wow; } else { hoge = 1; } } } wow:; } } if (ans == 1000) { cout << "-1" << endl; } else cout << ans+1 << endl; return 0; }