import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String args[] ) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = br.readLine(); int min = 101; int index = 0; int index1; int index2; while ((index1 = line.indexOf("c", index)) != -1) { index2 = line.indexOf("w", index1 + 1); if (index2 != -1) { index2 = line.indexOf("w", index2 + 1); if (index2 != -1) { int len = index2 - index1 + 1; if (min > len) { min = len; } } } index++; } if (min == 101) { System.out.println("-1"); } else { System.out.println(min); } } }