import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String S = scan.next(); scan.close(); ArrayList list = new ArrayList(); for(int i = 0; i < S.length(); i++) { char c = S.charAt(i); if(c == 'c') { list.add(i); } } int []ans = new int[list.size()]; Arrays.fill(ans, 101); for(int i = 0; i < list.size(); i++) { int cnt = 0; for(int j = list.get(i); j < S.length(); j++) { char c = S.charAt(j); if(c == 'w') { cnt ++; if(cnt == 2) { ans[i] = j - list.get(i) + 1; break; } } } } int min = ans[0]; for(int i = 1; i < ans.length; i++) { if(min > ans[i]) { min = ans[i]; } } if(min == 101) { min = -1; } System.out.println(min); } }