S = input() N = len(S) ans = N + 1 for i in range(N): for j in range(i + 1, N + 1): T = S[i:j] try: idx = T.index("c") idx = T.index("w", idx + 1) T.index("w", idx + 1) ans = min(ans, len(T)) except: continue if ans == N + 1: print(-1) else: print(ans)