import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static class Pair { public Integer status; public Integer length; public Pair(Integer s, Integer l) { this.status = s; this.length = l; } } public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String a = scanner.next(); String[] strArray = a.split(""); List pairList = new ArrayList(); for (String s : strArray) { if (s.equals("c")) { Pair pair = new Pair(0, 1); pairList.add(pair); } else if (s.equals("w")) { for (Pair p : pairList) { if (p.status == 2) { continue; } p.status++; p.length++; } } else { for (Pair p : pairList) { if (p.status == 2) { continue; } p.length++; } } } int minLength = 101; for (Pair p : pairList) { if (p.status == 2) { if (p.length < minLength) { minLength = p.length; } } } if (minLength == 101) { System.out.println(-1); } else { System.out.println(minLength); } } }