import re S = input() match = re.findall("c.+w.*w", S) if len(match) == 0: print(-1) else: print(min([len(x) for x in match]))