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){ line = ""; } int min = line.length(); int c = 0;//直前のcの位置 int w = 0;//直前のwの位置 boolean check = false; for(int i = 0; i < line.length(); i++){ if(line.charAt(i) == 'c') c = i; if(line.charAt(i) == '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"); } }