import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String S = sc.next(); char[] charS = S.toCharArray(); int i = 0, cnt = 0, flag = 0, cflag = 0, min = Integer.MAX_VALUE; while(i < charS.length) { if(charS[i] == 'c') { for(int j = i + 1; j < charS.length; j++) { if(charS[j] == 'c' && cflag == 0) { i = j; } if(charS[j] == 'w') { cnt++; if(cnt == 1) { cflag = 1; } if(cnt == 2) { if(j - i + 1 < min) { min = j - i + 1; charS = S.substring(j + 1).toCharArray(); flag = 1; } } } } } if(flag == 1) { i = 0; cnt = 0; cflag = 0; flag = 0; } else { cflag = 0; i++; } } if(min == Integer.MAX_VALUE) { System.out.println(-1); } else { System.out.println(min); } } }