import java.util.ArrayList; //未完成 import java.util.Scanner; import java.util.TreeSet; public class Mincww { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ Scanner s = new Scanner(System.in); StringBuilder cww = new StringBuilder(s.next()); s.close(); TreeSet clist = new TreeSet<>(); ArrayList wlist = new ArrayList<>(); while(cww.indexOf("c") != -1 || cww.indexOf("w") != -1){ int cn = cww.lastIndexOf("c"); int wn = cww.lastIndexOf("w"); if((cn != -1 && Math.max(cn, wn) == cn) || wn == -1){ clist.add(cn); cww.delete(cn,cww.length()+1); }else if(cn == -1 || (wn != -1 && Math.max(cn, wn) == wn)){ wlist.add(0,wn); cww.delete(wn,cww.length()+1); } } int count = -1; for(int c:clist){ int k =0; for(int i = 0;i < wlist.size();i++){ if(wlist.get(i) > c){ k++; if(k == 2){ int a = wlist.get(i)-c+1; if(count == -1){ count = a; }else{ count = Math.min(count, a); } } } } } System.out.println(count); } }