def solve(): S = input() L = len(S) ans = 114514 for i, c in enumerate(S): if c == 'c': nw = 0 for j in range(i + 1, L): w = S[j] if w == 'w': nw += 1 if nw >= 2: ans = min(ans, j - i + 1) if ans == 114514: print(-1) else: print(ans) if __name__ == '__main__': solve()