import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import static java.lang.System.in; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String S = reader.readLine(); int wCount = 0; int firstW = 0; int secondW = 0; int answer = Integer.MAX_VALUE; boolean found = false; for (int i = S.length() - 1; i >= 0; i--) { char current = S.charAt(i); if (current == 'w') { wCount += 1; if (wCount == 1) { firstW = i; } else if (wCount == 2) { secondW = i; } else { firstW = secondW; secondW = i; } // System.out.println("first ; " + firstW + " second; " + secondW); // } else if (current == 'c' && wCount >= 2) { // System.out.println("c; " + i + "first ; " + firstW + " second; " + secondW); answer = Math.min(answer, firstW - i + 1); found = true; } } if(found) { System.out.println(answer); } else { System.out.println(-1); } } }