import re S = input() cc = len(S) pat = re.compile(r'c.*?w.*?w') i = 0 ans = [] while i < cc: mob = pat.search(S,i) if mob: a, b = mob.span() bw = b - a ans.append(bw) i += 1 if ans == []: print(-1) else: print(min(ans))