import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; 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 min = line.length(); int c = 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 = i; if(chiwawa == 'w'){ if(c < w){ check = true; if(min > i - c + 1) min = i - c + 1; w = i; } else w = i; } } if(check) System.out.println(min); else System.out.println("-1"); } }