import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String S = sc.next(); int a = S.indexOf("c"); int min = Integer.MAX_VALUE; while(a!=-1){ S = S.substring(a+1); int b = S.indexOf("w"); String t = S.substring(b+1); int c = t.indexOf("w"); if(c!=-1 && min>b+c+3){ min = b+c+3; } a = S.indexOf("c"); } if(min==Integer.MAX_VALUE){ System.out.println(-1); }else{ System.out.println(min); } } }