#include #include #include #include #include int main() { int c = -1; int w1 = -1; int w2 = -1; int strNum = 999999999; int n = 0; char str[100001] = "ccwwcw"; scanf("%s", str); while(true) { int tmp = 0; for (int i = n;str[i] != '\0';i++) { if (str[i] == 'c' && c == -1) { c = i; break; } } for (int i = c + 1;str[i] != '\0';i++) { if (str[i] == 'w' && w1 == -1) { w1 = i; break; } } for (int i = w1 + 1;str[i] != '\0';i++) { if (str[i] == 'w' && w2 == -1) { w2 = i; break; } } if (c == -1 || w1 == -1 || w2 == -1) { break; } tmp = w2 - c + 1; if (tmp < strNum) { strNum = tmp; } c = -1; w1 = -1; w2 = -1; n++; } if (strNum > 100001) { printf("-1\n"); return 0; } printf("%d\n", strNum ); return 0; }