S = input() cwls = [None, None, None] cww = "cww" a = 0 for i in range(len(S)): if S[i] == cww[a] and cwls[a] == None: cwls[a] = i a += 1 if a == 3: break if None in cwls: print(-1) else: print(cwls[2] - cwls[0] + 1)