import re S = input() pattern = '.*?c.*?w.*?w' O = re.findall(pattern, S) if O == None: print('-1') else: print(len(min(O, key=len)))