// yukicoder: No.345 最小チワワ問題 // 2019.4.15 bal4u #include #include #include #include //// 高速入力 #if 1 #define gc() getchar_unlocked() #else #define gc() getchar() #endif // 文字列の入力 スペース以下の文字で入力終了 void ins(char *s) { do *s = gc(); while (*s++ > ' '); *(s - 1) = 0; } char S[105]; int getlen(char *p) { int f = 2; char *q = p; while (*p) { if (*p == 'w') if (--f == 0) return p - q + 1; p++; } return -1; } int main() { int a, ans; char *p; ins(S); ans = -1; p = S; while (*p) { if (*p == 'c' && (a = getlen(p)) > 0 && (ans < 0 || a < ans)) ans = a; p++; } printf("%d\n", ans); return 0; }