import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class QuestionA { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line; try{ line = in.readLine(); }catch(IOException e){ System.out.println("-1"); return; } int[] c = new int[100000]; Arrays.fill(c, 0); int min = line.length(); int ccount = 0;//直前のcの位置 int w = 0;//直前のwの位置 boolean check = false; int max = line.length(); for(int i = 0; i < max; i++){ char chiwawa =line.charAt(i); if(chiwawa == 'c'){ c[ccount]= i; ccount++; } if(chiwawa == 'w'){ if(w > 0 && ccount > 0){ check = true; for(int j = 0; j < ccount; j++){ if(c[j] < w && min > i - c[j] + 1){ min = i - c[j] + 1; } } w = i; } else w = i; } } if(check) System.out.println(min); else System.out.println("-1"); } }