S = input() L = [] for i, s in enumerate(S): if s == 'c': for j, t in enumerate(S[i+1:]): if t == 'w': for k, u in enumerate(S[i+j+2:]): if u == 'w': L.append([i, i+j+1, i+j+k+2]) break if len(L) == 0: print(-1) else: ans = [] for a, b, c in L: ans += [c-a+1] print(min(ans))