import re S = input() k = 100000000000000000000 l = list(S) l1 = [] #ans = re.findall("[c]+[^c]*[^w]*[w]+[^w]*[w]",S) #ans = re.findall("c.*?w.*?w",S) for i in range(len(l)): if l[i] == "c": matchOB = re.match("c.*?w.*?w",S[i:]) if matchOB: l1.append(len(matchOB.group())) if len(l1) > 0: print(min(l1)) else: print("-1")