import java.util.Scanner; public class Main_yukicoder345 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); char[] s = sc.next().toCharArray(); int n = s.length; int min = Integer.MAX_VALUE; for (int i = 0; i < n; i++) { if (s[i] != 'c') { continue; } else { int cnt = 0; int j; for (j = i + 1; j < n && cnt < 2; j++) { if (s[j] == 'w') { cnt++; } } if (cnt == 2) { min = Math.min(min, j - i); } } } if (min == Integer.MAX_VALUE) { System.out.println(-1); } else { System.out.println(min); } sc.close(); } }