import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; import java.util.regex.Pattern; import java.util.regex.Matcher; public class MinimumChihuahua { public static void main(String[] args){ Scanner scanner = new Scanner(System.in); try{ String S = scanner.next(); if(S.length() < 1 || S.length() > 100){ System.out.println("文字列は1以上100以下の文字数で入力してください"); System.exit(0); } Pattern pattern = Pattern.compile(".*[A-Z].*"); Matcher matcher = pattern.matcher(S); if(matcher.find()){ S = S.toLowerCase(); } char[] CS = S.toCharArray(); ArrayList Stock = new ArrayList<>(); int CountW = 0; for (int i = 0 ; i < CS.length ;i++){ if(CS[i] == 'c'){ for(int j = i ; j < CS.length ; j++){ if(CS[j] == 'w'){ CountW++; if(CountW == 2){ Stock.add((j + 1) - i ); break; } } } CountW = 0; } } if(Stock.isEmpty()){ System.out.println("-1"); }else{ Collections.sort(Stock); System.out.println(Stock.get(0)); } }catch(Exception E){ System.out.println("予期せぬエラーです"); } } }