#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define N 1000 #define re(i,n) for(int i=0;i<(n);i++) #define rep(i,a,b) for(int i=(a);i<(b);i++) #define fe(i,n,f) for_each(i,n,f) #define bw(a,b,c) (((a)<=(b))&&((b)<=(c))) using namespace std; typedef long long ll; typedef unsigned long long ull; int main(void){ string s; int n=0; int m=999; int state=0; cin>>s; re(i,s.size()){ switch (state) { case 0: if(s[i]=='c'){state=1;n=1;} break; case 1: n++; if(s[i]=='w')state=2; break; case 2: n++; if(s[i]=='w'){ state=0; m=min(m,n); } break; } } for(int i=s.size()-1;i>=0;i--){ switch (state) { case 0: if(s[i]=='w'){state=1;n=1;} break; case 1: n++; if(s[i]=='w')state=2; break; case 2: n++; if(s[i]=='c'){ state=0; m=min(m,n); } break; } } cout<<(m!=999?m:-1)<