import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); int n = s.length(); int ans = 1001001001; for(int i = 0 ; i < n ; i++) { if(s.charAt(i) == 'c') { int cnt = 0; for(int j = i + 1 ; j < n ; j++) { if(s.charAt(j) == 'w') { cnt++; if(cnt == 2) { ans = Math.min(ans, j - i + 1); } } } } } if(ans == 1001001001) { System.out.println(-1); } else { System.out.println(ans); } } }