import java.util.*; import java.util.regex.*; public class Main { public static void main(String[] args) throws Exception { var sc = new Scanner(System.in); String line = sc.next(); var pattern = Pattern.compile("c.*?w.*?w"); var matcher = pattern.matcher(line); int min = Integer.MAX_VALUE; while(matcher.find()){ //System.out.println(matcher.group()); min = Math.min(min, matcher.group().length()); } if(min == Integer.MAX_VALUE){ System.out.println(-1); }else{ System.out.println(min); } } }