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