import re pattern = re.compile(r'c.*w.*w') S = input() m = pattern.search(S) if m is None: print(-1) else: print(len(pattern.search(S).group(0)))