import sys input=lambda: sys.stdin.readline().rstrip() S=input() n=len(S) C=[] W=[] import bisect for i in range(n): if S[i]=="c": C.append(i) if S[i]=="w": W.append(i) if not C or not W: print(-1) else: ans=float("inf") for i in range(len(W)-1): w1,w2=W[i],W[i+1] if w1