#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #define _USE_MATH_DEFINES #include #include //#include //using namespace atcoder; using namespace std; #define REP(i,n) for(int i = 0; i < (int)n; i++) #define RREP(i,n) for(int i = (int)n-1; i >= 0; i--) #define LREP(i,n) for(LL i = 0; i < (LL)n; i++) #define Vi vector #define Vl vector #define LP pair #define P pair #define T3 tuple #define T4 tuple #define INF 1000000007 #define SIZE 3010 #define MOD 998244353 typedef long long LL; int N; string S; int main() { cin >> S; N = S.size(); int ans = INF; REP(i, N) { if (S[i] != 'w') continue; int l = -INF, r = INF; for (int j = i - 1; j >= 0; j--) { if (S[j] == 'c') { l = j; break; } } for (int j = i + 1; j < N; j++) { if (S[j] == 'w') { r = j; break; } } ans = min(ans, r - l + 1); } if (ans > N) ans = -1; cout << ans << endl; }