def main(): S = input() minlen = 101 len_ = 0 for i in range(len(S) - 2): if S[i] == 'c': len_ = 1 w = 0 for j in range(i + 1, len(S)): len_ += 1 if S[j] == 'w': w += 1 if w == 2: minlen = min(minlen, len_) break if minlen == 101: print(-1) else: print(minlen) main()