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