from bisect import bisect_left S = input() N = len(S) cnt_w = [0]*N for i, s in enumerate(S): if s == 'w': cnt_w[i] = 1 for i in range(1, N): cnt_w[i] += cnt_w[i - 1] ans = N + 1 for i in range(N): if S[i] == 'c': # cnt_w[i] + 2 が一番最初に出てくるマスは? r_idx = bisect_left(cnt_w, cnt_w[i] + 2) if r_idx <= N - 1: sub = r_idx - i + 1 if sub < ans: ans = sub if ans == N + 1: ans = -1 print(ans)