import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; class No345 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str = br.readLine(); int CW = str.indexOf("cw"); int C = 0; int W1 = 0; int W2 = 0; if (CW != -1) W2 = str.indexOf("w",CW+1); else { C =str.indexOf("c"); //cの位置 W1 = str.indexOf("w",C+1); //1つ目のwの位置 W2 = str.indexOf("w",W1+1); //2つ目のwの位置 } if (CW != -1 && W2 != -1) System.out.println( (W2 - CW) + 2); //"cw"と"w"がある時 else if (CW == -1 && C != -1 && W1 != -1 && W2 != -1 ) //"cw"がないが、cww全てが含まれる時 System.out.println( (W2 - C) + 1 ); else System.out.println(-1); } }