import re s = input() try: cww = min(map(len, re.findall('c[^cw]*w.*?w', s))) except: cww = -1 print(cww)