import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String text = scanner.next(); Pattern p = Pattern.compile("c.*w.*w"); Matcher m = p.matcher(text); int length = Integer.MAX_VALUE; while (m.find()) { int matched = m.group().length(); if (length > matched) { length = matched; } } if (length == Integer.MAX_VALUE) { length = -1; } System.out.println(length); } }