S = input() L = len(S) import re cand = [] for i in range(L-1): for j in range(i+1, L+1): if re.match(".*c.*w.*w.*",S[i:j]): cand += [j-i] if cand: print(min(cand)) else: print(-1)