import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); char[] inputs = sc.next().toCharArray(); int answer = Integer.MAX_VALUE; for(int fst = 0; fst < inputs.length; fst++){ if(inputs[fst] != 'c'){ continue; } for(int snd = fst + 1; snd < inputs.length; snd++){ if(inputs[snd] != 'w'){ continue; } for(int thd = snd + 1; thd < inputs.length; thd++){ if(inputs[thd] != 'w'){ continue; } answer = Math.min(answer, (thd - fst + 1)); } } } System.out.println(answer == Integer.MAX_VALUE ? -1 : answer); } }