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; if(a==-1){ System.out.println(-1); }else{ 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"); } System.out.println(min); } } }