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, min = Integer.MAX_VALUE; while(i < charS.length) { if(charS[i] == 'c') { for(int j = i + 1; j < charS.length; j++) { if(charS[j] == 'w') { cnt++; 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; flag = 0; } else { i++; } } if(min == Integer.MAX_VALUE) { System.out.println(-1); } else { System.out.println(min); } } }