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; int w1 = n; int w2 = n; for(int i = n - 1 ; i >= 0 ; i--) { if(s.charAt(i) == 'w') { w2 = w1; w1 = i; } else if(s.charAt(i) == 'c' && w2 != n){ ans = Math.min(ans, w2 - i + 1); } } System.out.println(ans == 1001001001 ? -1 : ans); } }